MCPcopy
hub / github.com/pytest-dev/pytest / test_make_hook_recorder

Function test_make_hook_recorder

testing/test_pytester.py:22–75  ·  view source on GitHub ↗
(pytester: Pytester)

Source from the content-addressed store, hash-verified

20
21
22def test_make_hook_recorder(pytester: Pytester) -> None:
23 item = pytester.getitem("def test_func(): pass")
24 recorder = pytester.make_hook_recorder(item.config.pluginmanager)
25 assert not recorder.getfailures()
26
27 # (The silly condition is to fool mypy that the code below this is reachable)
28 if 1 + 1 == 2:
29 pytest.xfail("internal reportrecorder tests need refactoring")
30
31 class rep:
32 excinfo = None
33 passed = False
34 failed = True
35 skipped = False
36 when = "call"
37
38 recorder.hook.pytest_runtest_logreport(report=rep) # type: ignore[attr-defined]
39 failures = recorder.getfailures()
40 assert failures == [rep] # type: ignore[comparison-overlap]
41 failures = recorder.getfailures()
42 assert failures == [rep] # type: ignore[comparison-overlap]
43
44 class rep2:
45 excinfo = None
46 passed = False
47 failed = False
48 skipped = True
49 when = "call"
50
51 rep2.passed = False
52 rep2.skipped = True
53 recorder.hook.pytest_runtest_logreport(report=rep2) # type: ignore[attr-defined]
54
55 modcol = pytester.getmodulecol("")
56 rep3 = modcol.config.hook.pytest_make_collect_report(collector=modcol)
57 rep3.passed = False
58 rep3.failed = True
59 rep3.skipped = False
60 recorder.hook.pytest_collectreport(report=rep3) # type: ignore[attr-defined]
61
62 passed, skipped, failed = recorder.listoutcomes()
63 assert not passed and skipped and failed
64
65 numpassed, numskipped, numfailed = recorder.countoutcomes()
66 assert numpassed == 0
67 assert numskipped == 1
68 assert numfailed == 1
69 assert len(recorder.getfailedcollections()) == 1
70
71 recorder.unregister() # type: ignore[attr-defined]
72 recorder.clear()
73 recorder.hook.pytest_runtest_logreport(report=rep3) # type: ignore[attr-defined]
74 with pytest.raises(ValueError):
75 recorder.getfailures()
76
77
78def test_parseconfig(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 11

getfailuresMethod · 0.80
listoutcomesMethod · 0.80
countoutcomesMethod · 0.80
getfailedcollectionsMethod · 0.80
getitemMethod · 0.45
make_hook_recorderMethod · 0.45
getmodulecolMethod · 0.45
pytest_collectreportMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…