pytest: Test directory structure and import problems

Hi!

I don’t know if problems with the documentation are to be posted here…

In the Test directory structure page:

Typically you can run tests by pointing to test directories or modules:

pytest tests/test_appmodule.py      # for external test dirs
pytest src/tests/test_appmodule.py  # for inlined test dirs
pytest src                          # run tests in all below test directories
pytest                              # run all tests below current dir

These are not working out of the box because of the path problem.
You will have something like:

tests/test_appmodule.py:1: in <module>
    from appmodule import <whatever>
E   ModuleNotFoundError: No module named 'appmodule'

I’ve wrote a question on stackoverflow here.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 19 (13 by maintainers)

Most upvoted comments

Created issues to track what to do with those branches: https://github.com/pytest-dev/pytest/issues/4119 and #4120. 👍