Skip to content

Testing an __init__.py file tests the entire package  #9263

@spagh-eddie

Description

@spagh-eddie

I found a difference between 6.1.2 and 6.2.0. I would have expected the behavior of only testing package/__init__.py, but in 6.2.0 it tests the entirety of package/.

I think it might be due to #8016 but I am not familiar with the internals of this library.

% tree                     
.
└── package
    ├── __init__.py
    └── dont_test_me.py

% cat package/__init__.py 
"""
>>> round(22/7, 2) == 3.14
True
"""

% cat package/dont_test_me.py 
"""
>>> 2 + 2 == 5
True
"""
% pip install pytest==6.1.2  
% pytest -q --tb=no --doctest-modules package/__init__.py
.                                                                                  [100%]
1 passed in 0.02s

% pip install pytest==6.2.0  
% pytest -q --tb=no --doctest-modules package/__init__.py
.F                                                                                 [100%]
================================ short test summary info =================================
FAILED package/dont_test_me.py::package.dont_test_me
1 failed, 1 passed in 0.02s

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: collectionrelated to the collection phasetype: regressionindicates a problem that was introduced in a release which was working previously

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions