realpython / realpython/python-guide

Request: Add notes about where to put unit tests

未关闭
#492 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Batchfile
星标
29.8k
派生
5.9k
PR 合并指标
30 天内没有已合并 PR

描述

I did some Googling. None of the pages have very good explanations of where to put your unit test files.

Also, AFAIK (I am a Python newbiew) there are some drawbacks to <project_root>/test/ about importing. Might need to modify PYTHONPATH during unit test runs.

Also, please talk about why init.py is important for unit tests. A few places recommend it... but I thought it was dead in Python3.

Ref: http://pytest.org/latest/goodpractises.html
Ref: http://stackoverflow.com/questions/5341006/where-should-i-put-tests-when-packaging-python-modules
Ref: http://stackoverflow.com/questions/61151/where-do-the-python-unit-tests-go

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

未指定目标文件或测试。首先查看链接的 pytest 最佳实践和打包相关讨论,然后找到相关的测试文档。完成的标准是说明测试文件的放置位置、import/PYTHONPATH 方面的注意事项,以及 init.py 在 Python 3 中的作用。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
documentation, testing-qa
Issue 类型
文档
难度
2/5
预计耗时
半天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。