Skip to content

Commit 8a3c06e

Browse files
committed
Ignore coverage of a test function skipped mid-way
This causes the coverage CI to fail whenever touching this file, so nest the skipped parts in a `pragma: no cover`.
1 parent cae1148 commit 8a3c06e

File tree

1 file changed

+45
-45
lines changed

1 file changed

+45
-45
lines changed

testing/test_pytester.py

+45-45
Original file line numberDiff line numberDiff line change
@@ -24,51 +24,51 @@ def test_make_hook_recorder(testdir) -> None:
2424
assert not recorder.getfailures()
2525

2626
pytest.xfail("internal reportrecorder tests need refactoring")
27-
28-
class rep:
29-
excinfo = None
30-
passed = False
31-
failed = True
32-
skipped = False
33-
when = "call"
34-
35-
recorder.hook.pytest_runtest_logreport(report=rep)
36-
failures = recorder.getfailures()
37-
assert failures == [rep]
38-
failures = recorder.getfailures()
39-
assert failures == [rep]
40-
41-
class rep2:
42-
excinfo = None
43-
passed = False
44-
failed = False
45-
skipped = True
46-
when = "call"
47-
48-
rep2.passed = False
49-
rep2.skipped = True
50-
recorder.hook.pytest_runtest_logreport(report=rep2)
51-
52-
modcol = testdir.getmodulecol("")
53-
rep3 = modcol.config.hook.pytest_make_collect_report(collector=modcol)
54-
rep3.passed = False
55-
rep3.failed = True
56-
rep3.skipped = False
57-
recorder.hook.pytest_collectreport(report=rep3)
58-
59-
passed, skipped, failed = recorder.listoutcomes()
60-
assert not passed and skipped and failed
61-
62-
numpassed, numskipped, numfailed = recorder.countoutcomes()
63-
assert numpassed == 0
64-
assert numskipped == 1
65-
assert numfailed == 1
66-
assert len(recorder.getfailedcollections()) == 1
67-
68-
recorder.unregister()
69-
recorder.clear()
70-
recorder.hook.pytest_runtest_logreport(report=rep3)
71-
pytest.raises(ValueError, recorder.getfailures)
27+
if False: # pragma: no cover
28+
class rep:
29+
excinfo = None
30+
passed = False
31+
failed = True
32+
skipped = False
33+
when = "call"
34+
35+
recorder.hook.pytest_runtest_logreport(report=rep)
36+
failures = recorder.getfailures()
37+
assert failures == [rep]
38+
failures = recorder.getfailures()
39+
assert failures == [rep]
40+
41+
class rep2:
42+
excinfo = None
43+
passed = False
44+
failed = False
45+
skipped = True
46+
when = "call"
47+
48+
rep2.passed = False
49+
rep2.skipped = True
50+
recorder.hook.pytest_runtest_logreport(report=rep2)
51+
52+
modcol = testdir.getmodulecol("")
53+
rep3 = modcol.config.hook.pytest_make_collect_report(collector=modcol)
54+
rep3.passed = False
55+
rep3.failed = True
56+
rep3.skipped = False
57+
recorder.hook.pytest_collectreport(report=rep3)
58+
59+
passed, skipped, failed = recorder.listoutcomes()
60+
assert not passed and skipped and failed
61+
62+
numpassed, numskipped, numfailed = recorder.countoutcomes()
63+
assert numpassed == 0
64+
assert numskipped == 1
65+
assert numfailed == 1
66+
assert len(recorder.getfailedcollections()) == 1
67+
68+
recorder.unregister()
69+
recorder.clear()
70+
recorder.hook.pytest_runtest_logreport(report=rep3)
71+
pytest.raises(ValueError, recorder.getfailures)
7272

7373

7474
def test_parseconfig(testdir) -> None:

0 commit comments

Comments
 (0)