Skip to content

Commit 3a6bdcd

Browse files
authored
Merge pull request #11055 from bluetech/lf-skipped-package
cacheprovider: fix file-skipping feature for files in packages
2 parents 9e1add7 + fc538c5 commit 3a6bdcd

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

changelog/11054.bugfix.rst

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def __init__(self, lfplugin: "LFPlugin") -> None:
219219

220220
@hookimpl(hookwrapper=True)
221221
def pytest_make_collect_report(self, collector: nodes.Collector):
222-
if isinstance(collector, Session):
222+
if isinstance(collector, (Session, Package)):
223223
out = yield
224224
res: CollectReport = out.get_result()
225225

testing/test_cacheprovider.py

Lines changed: 7 additions & 1 deletion
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)