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.

pytest_collection_modifyitems in subdir conftest recieves all tests

See original GitHub issue

Given the following test setup:

tests
| - a
    | - __init__.py
    | - conftest.py
    | - test_foo.py  
| - __init__.py
| - test_bar.py
# a/conftest.py
def pytest_collection_modifyitems(items):
    for item in items:
        print(item.name)
# a/test_foo.py
def test_foo():
    pass
# test_bar.py
def test_bar():
    pass

Based on the docs, I wouldn’t expect to see “test_bar” be printed, but I do.


Debug:

Package            Version
------------------ -------
atomicwrites       1.4.0
attrs              19.3.0
colorama           0.4.3
importlib-metadata 1.6.0
more-itertools     8.2.0
packaging          20.3
pip                10.0.1
pluggy             0.13.1
py                 1.8.1
pyparsing          2.4.7
pytest             5.4.2
setuptools         39.0.1
six                1.14.0
wcwidth            0.1.9
zipp               3.1.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
thejcannoncommented, Sep 30, 2020

@The-Compiler @nimeshvashistha My bad 😅 September has been a very busy month.

Put me on the PR when it’s ready. I haven’t had much runtime with the Python documentation ecosystem and would love a reason to get familiar 😄

0reactions
nimeshvashisthacommented, Sep 30, 2020

@nimeshvashistha Since @thejcannon didn’t answer for a couple of weeks it seems fine to take this - as discussed, only the doc addition without any behavior/code changes for now. Thanks!

alright, thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pytest marks: mark entire directory / package - Stack Overflow
The way I am currently doing this is for each test module, I add a pytest marker and then specify the marker from...
Read more >
Writing plugins — pytest documentation
Writing plugins¶. It is easy to implement local conftest plugins for your own project or pip-installable plugins that can be used throughout many...
Read more >
pytest Documentation - Read the Docs
pytest discovers all tests following its Conventions for Python ... the test module and get the custom output defined in the conftest file:....
Read more >
Writing plugins — pytest documentation
by loading all conftest.py files as inferred by the command line invocation: ... is called for tests in the a sub directory but...
Read more >
Testing with files and directories - Testfixtures - Read the Docs
These have an array of methods that let you perform common file and directory related tasks without all the manual boiler plate. The...
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