Skip to content

pytest==8.3.1 collects tests from Python dependencies within conda environments (regression from 8.2.2) #12652

Closed
@joshuacwnewton

Description

@joshuacwnewton
  • a detailed description of the bug or problem you are having
  • output of pip list from the virtual environment you are using
  • pytest and operating system versions
    • 8.3.1, multiple different GitHub Actions runners (windows-2019, ubuntu-2022, etc.)
  • minimal example if possible

We have the following setup.cfg file:

[tool:pytest]
addopts = --verbose --show-capture=stderr --tb=native
python_files = testing/**/test_*.py
# NB: norecursedirs is *not* set

When running pytest (with no additional options) in the root of our repository, we see the following behavior:

  • pytest==8.2.2: Only our tests are collected.
  • pytest==8.3.1: Our tests and the tests of our dependencies are collected, leading to many errors.
    • collecting ... collected 367457 items / 408 errors / 100 skipped (Woof!)

Changing our setup.cfg to the following didn't fix the problem either:

[tool:pytest]
addopts = --verbose --show-capture=stderr --tb=native
testpaths = testing
python_files = test_*.py

The fix I used was adding norecursedirs = {name_of_venv}


Since this involves collection in virtual environments, the reason for the regression might be related to changes in:

Notably, we use a conda env with pip packages installed inside, which may subvert the expectations of the changes in the above PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions