MCPcopy Index your code
hub / github.com/pytest-dev/pytest / test_messages

Function test_messages

testing/logging/test_fixture.py:250–268  ·  view source on GitHub ↗
(caplog: pytest.LogCaptureFixture)

Source from the content-addressed store, hash-verified

248
249
250def test_messages(caplog: pytest.LogCaptureFixture) -> None:
251 caplog.set_level(logging.INFO)
252 logger.info("boo %s", "arg")
253 logger.info("bar %s\nbaz %s", "arg1", "arg2")
254 assert "boo arg" == caplog.messages[0]
255 assert "bar arg1\nbaz arg2" == caplog.messages[1]
256 assert caplog.text.count("\n") > len(caplog.messages)
257 assert len(caplog.text.splitlines()) > len(caplog.messages)
258
259 try:
260 raise Exception("test")
261 except Exception:
262 logger.exception("oops")
263
264 assert "oops" in caplog.text
265 assert "oops" in caplog.messages[-1]
266 # Tracebacks are stored in the record and not added until the formatter or handler.
267 assert "Exception" in caplog.text
268 assert "Exception" not in caplog.messages[-1]
269
270
271def test_record_tuples(caplog: pytest.LogCaptureFixture) -> None:

Callers

nothing calls this directly

Calls 1

set_levelMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…