PATH issue with pytest 'ImportError: No module named ...'
Full error message
I used easy_install to install pytest on a Mac and started writing tests for a project with a file structure likes so:
repo/
|--app.py
|--settings.py
|--models.py
|--tests/
|--test_app.py
Run py.test while in the repo directory, and everything behaves as you would expect.
But when I try that same thing on either Linux or Windows (both have pytest 2.2.3 on them), it barks whenever it hits its first import of something from my application path. For instance, from app import some_def_in_app.
Do I need to be editing my PATH to run py.test on these systems?Solutionsource: stackoverflow \u2197
I'm not sure why py.test does not add the current directory in the PYTHONPATH itself, but here's a workaround (to be executed from the root of your repository): python -m pytest tests/ It works because Python adds the current directory in the PYTHONPATH for you.
API access
Get this solution programmatically \u2014 free, no authentication.
curl https://depscope.dev/api/error/794c370b06ef3d624e2c6fd8fdf66edf8b7ad745c6490b36ff60f531a5707ecehash \u00b7 794c370b06ef3d624e2c6fd8fdf66edf8b7ad745c6490b36ff60f531a5707ece