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

Function test_logging_emit_error

testing/logging/test_reporting.py:1118–1141  ·  view source on GitHub ↗

An exception raised during emit() should fail the test. The default behavior of logging is to print "Logging error" to stderr with the call stack and some extra details. pytest overrides this behavior to propagate the exception.

(pytester: Pytester)

Source from the content-addressed store, hash-verified

1116
1117
1118def test_logging_emit_error(pytester: Pytester) -> None:
1119 """An exception raised during emit() should fail the test.
1120
1121 The default behavior of logging is to print "Logging error"
1122 to stderr with the call stack and some extra details.
1123
1124 pytest overrides this behavior to propagate the exception.
1125 """
1126 pytester.makepyfile(
1127 """
1128 import logging
1129
1130 def test_bad_log():
1131 logging.warning('oops', 'first', 2)
1132 """
1133 )
1134 result = pytester.runpytest()
1135 result.assert_outcomes(failed=1)
1136 result.stdout.fnmatch_lines(
1137 [
1138 "====* FAILURES *====",
1139 "*not all arguments converted during string formatting*",
1140 ]
1141 )
1142
1143
1144def test_logging_emit_error_supressed(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 4

assert_outcomesMethod · 0.80
fnmatch_linesMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected