question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Negation filter deselects all tests if it contains a part of the path of rootdir

See original GitHub issue

pip 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:open
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
RonnyPfannschmidtcommented, Sep 30, 2019

a non-root cause fix adding a pytest option/configuration to disable considering the session rootdir as a keyword can be applied more easily

0reactions
RonnyPfannschmidtcommented, Jan 11, 2020

@erheron as per the linked code fragments prior, Session is a FSCollector with the fspath attribute set to self.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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found