MCPcopy Index your code
hub / github.com/python-telegram-bot/python-telegram-bot / test_warn

Method test_warn

tests/test_warnings.py:68–87  ·  view source on GitHub ↗
(self, recwarn)

Source from the content-addressed store, hash-verified

66 make_assertion(PTBUserWarning)
67
68 def test_warn(self, recwarn):
69 expected_file = SOURCE_ROOT_PATH / "_utils" / "warnings.py"
70
71 warn("test message")
72 assert len(recwarn) == 1
73 assert recwarn[0].category is PTBUserWarning
74 assert str(recwarn[0].message) == "test message"
75 assert Path(recwarn[0].filename) == expected_file, "incorrect stacklevel!"
76
77 warn("test message 2", category=PTBRuntimeWarning)
78 assert len(recwarn) == 2
79 assert recwarn[1].category is PTBRuntimeWarning
80 assert str(recwarn[1].message) == "test message 2"
81 assert Path(recwarn[1].filename) == expected_file, "incorrect stacklevel!"
82
83 warn(PTBDeprecationWarning("20.6", "test message 3"), stacklevel=1)
84 assert len(recwarn) == 3
85 assert recwarn[2].category is PTBDeprecationWarning
86 assert str(recwarn[2].message) == "Deprecated since version 20.6: test message 3"
87 assert Path(recwarn[2].filename) == Path(__file__), "incorrect stacklevel!"

Callers

nothing calls this directly

Calls 2

warnFunction · 0.90

Tested by

no test coverage detected