Skip to content

Problem with running tests in package's __init__ #4046

Closed
@pstiasny

Description

@pstiasny

This might be related to #3749 and/or #3773.

Given the following directory structure:

tests/
  __init__.py (1)
  test_foo.py (2)

and following setup.cfg:

[tool:pytest]
python_files = test_*.py __init__.py

Before py.test 3.7:

  • py.test with no arguments would collect tests in (1) and (2)
  • py.test tests/ would collect tests in (1) and (2)
  • py.test tests/__init__.py would collect tests in (1)

Until 3.8.1 collecting from __init__.py would not work due to #3749.

In 3.8.1 collecting from __init__.py works again, but:

  • py.test with no arguments would behave as before, collecting all tests correctly
  • py.test tests/ would collect tests in (2), omitting (1)
  • py.test tests/__init__.py would collect tests in (1), but also in (2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: collectionrelated to the collection phasetype: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions