realpython / realpython/python-guide

Request: Add notes about where to put unit tests

Open
#492 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Batchfile
Stars
29.8k
Forks
5.9k
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No target file or test is named. Start by reviewing the linked pytest good-practices and packaging discussions, then locate the relevant testing documentation; done means explaining test-file placement, import/PYTHONPATH considerations, and the role of init.py in Python 3.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation, testing-qa
Issue type
Documentation
Difficulty
2/5
Estimated time
Half a day
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.