Skip to content

Commit 30a1125

Browse files
bluetechpytestbot
authored andcommittedMay 30, 2023·
[7.3.x] cacheprovider: fix file-skipping feature for files in packages
1 parent 682fc81 commit 30a1125

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed
 

‎changelog/11054.bugfix.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed ``--last-failed``'s "(skipped N files)" functionality for files inside of packages (directories with `__init__.py` files).

‎src/_pytest/cacheprovider.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def __init__(self, lfplugin: "LFPlugin") -> None:
213213

214214
@hookimpl(hookwrapper=True)
215215
def pytest_make_collect_report(self, collector: nodes.Collector):
216-
if isinstance(collector, Session):
216+
if isinstance(collector, (Session, Package)):
217217
out = yield
218218
res: CollectReport = out.get_result()
219219

‎testing/test_cacheprovider.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,13 @@ def test_fail(val):
420420
result = pytester.runpytest()
421421
result.stdout.fnmatch_lines(["*1 failed in*"])
422422

423-
def test_terminal_report_lastfailed(self, pytester: Pytester) -> None:
423+
@pytest.mark.parametrize("parent", ("session", "package"))
424+
def test_terminal_report_lastfailed(self, pytester: Pytester, parent: str) -> None:
425+
if parent == "package":
426+
pytester.makepyfile(
427+
__init__="",
428+
)
429+
424430
test_a = pytester.makepyfile(
425431
test_a="""
426432
def test_a1(): pass

0 commit comments

Comments
 (0)
Please sign in to comment.