Pytest test discovery confused by packages
See original GitHub issueEnvironment data
- VS Code version: 1.30.2
- Extension version (available under the Extensions sidebar): 2018.12.1
- Relevant/affected Python packages and their versions: pytest 3.9.1
Expected behaviour
Tests are discovered correctly
Actual behaviour
Any package causes subsequently discovered tests to be considered IN the package
Steps to reproduce:
- Create a tests folder
- Create test/testa/test_first.py test/testc/test_last.py with regular python tests (any function will suffice)
- Create test/testb/init.py and test/testb/test_second.py with a python test function
- Run discover tests
Logs
Example pytest output:
============================= test session starts ==============================
platform linux -- Python 3.6.0, pytest-3.9.1, py-1.7.0, pluggy-0.8.0
Using --randomly-seed=1547049040
rootdir: /home/alex/git/HP-DLF, inifile:
plugins: repeat-0.7.0, randomly-1.2.3, profiling-1.3.0, cov-2.6.0, console-scripts-0.1.7, nbval-0.9.1
collected 3 items
<Module 'test/testa/test_first.py'>
<Function 'test_foo'>
<Package '/home/.../test/testb'>
<Module 'test_second.py'>
<Function 'test_foo'>
<Module 'test/testc/test_last.py'>
<Function 'test_foo'>
========================= no tests ran in 0.11 seconds =========================
The test output parser will report the last one in file /home/.../test/testb/test/testc/test_last.py
which is clearly wrong.
Reason is that the packagePrefix is not reset
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
Changing standard (Python) test discovery - Pytest
Default behavior of pytest is to ignore duplicate paths specified from the command line. Example: ; To collect duplicate tests, use the --keep-duplicates...
Read more >How should I structure a pytest test only package?
I created a python package which just contains test related stuff like pytest tests, pytest fixtures, test helper functions in util modules, ...
Read more >pytest Documentation - Read the Docs
pytest discovers all tests following its Conventions for Python test discovery, so it finds both test_ prefixed functions.
Read more >Getting Started With Testing in Python
In this in-depth tutorial, you'll see how to create Python unit tests, ... you want to place test.py above the package folder, so...
Read more >UnitTest Framework - Py.test Module - Tutorialspoint
UnitTest Framework - Py.test Module, It was in 2004 that Holger Krekel renamed his std package, whose name was often confused with that...
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
Any time frame on when this will be released? It currently makes the pytest integration unusable for me.
This should be resolved in the most recent versions of the Python extension. If that is not the case then please create a new issue. (This one has a bit of outdated info, so better to start fresh.)