(caplog: pytest.LogCaptureFixture)
| 248 | |
| 249 | |
| 250 | def 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 | |
| 271 | def test_record_tuples(caplog: pytest.LogCaptureFixture) -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…