Negation filter deselects all tests if it contains a part of the path of rootdir
See original GitHub issuepip list
atomicwrites (1.3.0) attrs (19.1.0) importlib-metadata (0.23) more-itertools (7.2.0) packaging (19.2) pip (9.0.1) pkg-resources (0.0.0) pluggy (0.13.0) py (1.8.0) pyparsing (2.4.2) pytest (5.2.0) setuptools (39.0.1) six (1.12.0) wcwidth (0.1.7) zipp (0.6.0)
pytest and operating system versions
pytest-5.2.0 ubuntu 18.04 x64
Reproducer
$ pwd
/tmp/another_dir
$ cat test_pytest_bug.py
def test_pytest():
assert True
$ cd /tmp/some_dir
$ pytest -v -o testpaths="/tmp/another_dir" -k "not some_dir"
==========================test session starts===============================
platform linux -- Python 3.6.8, pytest-5.2.0, py-1.8.0, pluggy-0.13.0 -- /tmp/test/bin/python3
cachedir: .pytest_cache
rootdir: /tmp/some_dir, testpaths: /tmp/another_dir
collected 1 item / 1 deselected
$ cd /tmp/another_dir
$ pytest -v -o testpaths="/tmp/another_dir" -k "not some_dir"
==========================test session starts===============================
platform linux -- Python 3.6.8, pytest-5.2.0, py-1.8.0, pluggy-0.13.0 -- /tmp/test/bin/python3
cachedir: .pytest_cache
rootdir: /tmp/another_dir, testpaths: .
collected 1 item
test_pytest_bug.py::test_pytest PASSED
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Change pytest rootdir - Stack Overflow
The rootdir in Pytest has no connection to how test package names are constructed and rootdir is not added to sys.path , as...
Read more >Changing standard (Python) test discovery - Pytest
Deselect tests during test collection Tests can individually be deselected during collection by passing the --deselect=item option.
Read more >pytest Documentation - Read the Docs
pytest will run all files of the form test_*.py or *_test.py in the current directory and its subdirectories. More generally,.
Read more >API Reference — pytest documentation - Read the Docs
This page contains the full reference to pytest's API. Functions ... autouse – if True, the fixture func is activated for all tests...
Read more >Manual - Vifm
Vifm is a file manager with curses interface, which provides Vim-like environment ... Files excluded this way are not counted as filtered out...
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 Free
Top 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
a non-root cause fix adding a pytest option/configuration to disable considering the session rootdir as a keyword can be applied more easily
@erheron as per the linked code fragments prior,
Session
is aFSCollector
with thefspath
attribute set toself.rootdir
that element is also taken in as keword via that path
so the workaround would be to have session drop its keyword for its path, which is rootdir