Skip to content

Commit 84a499f

Browse files
Make empty-file test tolerant of a real Python-version behavior split
An empty module compiles to a single line-1 entry on Python 3.9/3.10 (findlinestarts -> (0, 1)) but to (0, 0) on 3.11+, which slipcover's own line-collection already filters out as non-real. So an empty .py file legitimately has 1 trivially-executed line on 3.9/3.10 and 0 on 3.11+ -- both correct, and not something to "fix" in slipcover itself. The test's hardcoded LF:0/LH:0 assumption only held on 3.11+. Assert the actual invariant instead: no DA: line reports a zero hit count, i.e. nothing is missing, regardless of the exact (version-dependent) line count. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 86208f2 commit 84a499f

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

tests/test_coverage.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,6 +1605,11 @@ def test_lcov_normalizes_windows_paths():
16051605

16061606

16071607
def test_lcov_flag_empty_file(tmp_path, monkeypatch):
1608+
"""An empty .py file has no missing coverage. The exact line count is
1609+
NOT asserted: Python 3.9/3.10 report one (trivially-executed) line for
1610+
an empty module, while 3.11+ report none -- both are correct, since
1611+
what matters here is that nothing is reported as missing.
1612+
"""
16081613
monkeypatch.chdir(tmp_path)
16091614
(tmp_path / "empty.py").write_text("")
16101615

@@ -1615,8 +1620,7 @@ def test_lcov_flag_empty_file(tmp_path, monkeypatch):
16151620
lines = lcov_text.strip().split('\n')
16161621

16171622
assert 'SF:empty.py' in lines[0]
1618-
assert 'LF:0' in lines
1619-
assert 'LH:0' in lines
1623+
assert not any(line.startswith('DA:') and line.endswith(',0') for line in lines)
16201624
assert 'end_of_record' in lines
16211625

16221626

0 commit comments

Comments
 (0)