MCPcopy Create free account
hub / github.com/hynek/structlog / test_clears_args

Method test_clears_args

tests/test_stdlib.py:1120–1134  ·  view source on GitHub ↗

We render our log records before sending it back to logging. Therefore we must clear `LogRecord.args` otherwise the user gets an `TypeError: not all arguments converted during string formatting.` if they use positional formatting in stdlib logging.

(self, capsys)

Source from the content-addressed store, hash-verified

1118 assert isinstance(calls[0]["_record"], logging.LogRecord)
1119
1120 def test_clears_args(self, capsys):
1121 """
1122 We render our log records before sending it back to logging. Therefore
1123 we must clear `LogRecord.args` otherwise the user gets an
1124 `TypeError: not all arguments converted during string formatting.` if
1125 they use positional formatting in stdlib logging.
1126 """
1127 configure_logging(None)
1128
1129 logging.getLogger().warning("hello %s.", "world")
1130
1131 assert (
1132 "",
1133 "hello world. [in test_clears_args]\n",
1134 ) == capsys.readouterr()
1135
1136 def test_pass_foreign_args_true_sets_positional_args_key(self):
1137 """

Callers

nothing calls this directly

Calls 2

configure_loggingFunction · 0.85
warningMethod · 0.45

Tested by

no test coverage detected