`poetry run pytest tests` cannot import current project if tests/__init__.py does not exist
See original GitHub issueRan into this with Poetry 0.8.6. To reproduce this, you can delete tests/__init__.py
in the Poetry project itself, then run poetry run pytest tests
. On commit 4829967a37fc74b3b7715986867fbd2ade29b514, I get 25 failures on ModuleNotFoundError: No module named 'poetry'
. Pytest doesn’t normally require __init__.py
files, so this is surprising.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:5 (1 by maintainers)
Top Results From Across the Web
sub module not found with poetry run pytest - Stack Overflow
So now the problem is: if I do a test for functions.py, I import like so : from project.collect_data.functions import my_function and this...
Read more >How to invoke pytest — pytest documentation
This will execute all tests in all files whose names follow the form test_*.py or \*_test.py in the current directory and its subdirectories....
Read more >Testing Python in Visual Studio Code
Support for running tests in parallel with pytest is available through the pytest-xdist package. To enable parallel testing: Open the integrated terminal and ......
Read more >Why does PyCharm not run pytest testing for my application?
I want to test the db.py module. I configure pycharm to use pytest as my test runner ( I verified this). When I...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It looks like you need to do
poetry add --dev pytest
for it to work withpoetry run pytest tests/
. Otherwise it will not be adding your project folder to the PYTHONPATHThis works correctly in the latest version of Poetry (0.12.4). Looks like the fix came from 0.12.0 installing the current project in editable mode when you run
poetry install
, so now Pytest can find the current project without needing the project folder manually added toPYTHONPATH
.