MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_recording

Method test_recording

testing/test_recwarn.py:42–56  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

40
41class TestWarningsRecorderChecker:
42 def test_recording(self) -> None:
43 rec = WarningsRecorder(_ispytest=True)
44 with rec:
45 assert not rec.list
46 warnings.warn_explicit("hello", UserWarning, "xyz", 13)
47 assert len(rec.list) == 1
48 warnings.warn(DeprecationWarning("hello"))
49 assert len(rec.list) == 2
50 warn = rec.pop()
51 assert str(warn.message) == "hello"
52 values = rec.list
53 rec.clear()
54 assert len(rec.list) == 0
55 assert values is rec.list
56 pytest.raises(AssertionError, rec.pop)
57
58 def test_warn_stacklevel(self) -> None:
59 """#4243"""

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