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

Method test_recording

testing/test_recwarn.py:86–101  ·  testing/test_recwarn.py::TestWarningsRecorderChecker.test_recording
(self)

Source from the content-addressed store, hash-verified

84
85class TestWarningsRecorderChecker:
86 def test_recording(self) -> None:
87 rec = WarningsRecorder(_ispytest=True)
88 with rec:
89 assert not rec.list
90 warnings.warn_explicit(class="st">"hello", UserWarning, class="st">"xyz", 13)
91 assert len(rec.list) == 1
92 warnings.warn(DeprecationWarning(class="st">"hello"))
93 assert len(rec.list) == 2
94 warn = rec.pop()
95 assert str(warn.message) == class="st">"hello"
96 values = rec.list
97 rec.clear()
98 assert len(rec.list) == 0
99 assert values is rec.list
100 with pytest.raises(AssertionError):
101 rec.pop()
102
103 def test_warn_stacklevel(self) -> None:
104 class="st">""class="st">"class="cm">#4243"class="st">""

Callers

nothing calls this directly

Calls 4

popMethod · 0.95
clearMethod · 0.95
WarningsRecorderClass · 0.90
warnMethod · 0.45

Tested by

no test coverage detected