Skip to content

Commit

Permalink
[7.3.x] cacheprovider: fix file-skipping feature for files in packages
Browse files Browse the repository at this point in the history
  • Loading branch information
bluetech authored and pytestbot committed May 30, 2023
1 parent 682fc81 commit 30a1125
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog/11054.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed ``--last-failed``'s "(skipped N files)" functionality for files inside of packages (directories with `__init__.py` files).
2 changes: 1 addition & 1 deletion src/_pytest/cacheprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def __init__(self, lfplugin: "LFPlugin") -> None:

@hookimpl(hookwrapper=True)
def pytest_make_collect_report(self, collector: nodes.Collector):
if isinstance(collector, Session):
if isinstance(collector, (Session, Package)):
out = yield
res: CollectReport = out.get_result()

Expand Down
8 changes: 7 additions & 1 deletion testing/test_cacheprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,13 @@ def test_fail(val):
result = pytester.runpytest()
result.stdout.fnmatch_lines(["*1 failed in*"])

def test_terminal_report_lastfailed(self, pytester: Pytester) -> None:
@pytest.mark.parametrize("parent", ("session", "package"))
def test_terminal_report_lastfailed(self, pytester: Pytester, parent: str) -> None:
if parent == "package":
pytester.makepyfile(
__init__="",
)

test_a = pytester.makepyfile(
test_a="""
def test_a1(): pass
Expand Down

0 comments on commit 30a1125

Please sign in to comment.