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

Function test_teardown_logging

testing/logging/test_reporting.py:148–172  ·  view source on GitHub ↗
(pytester: Pytester)

Source from the content-addressed store, hash-verified

146
147
148def test_teardown_logging(pytester: Pytester) -> None:
149 pytester.makepyfile(
150 """
151 import logging
152
153 logger = logging.getLogger(__name__)
154
155 def test_foo():
156 logger.info('text going to logger from call')
157
158 def teardown_function(function):
159 logger.info('text going to logger from teardown')
160 assert False
161 """
162 )
163 result = pytester.runpytest("--log-level=INFO")
164 assert result.ret == 1
165 result.stdout.fnmatch_lines(
166 [
167 "*- Captured *log call -*",
168 "*text going to logger from call*",
169 "*- Captured *log teardown -*",
170 "*text going to logger from teardown*",
171 ]
172 )
173
174
175@pytest.mark.parametrize("enabled", [True, False])

Callers

nothing calls this directly

Calls 3

fnmatch_linesMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected