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

Function test_setup_logging

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

Source from the content-addressed store, hash-verified

119
120
121def test_setup_logging(pytester: Pytester) -> None:
122 pytester.makepyfile(
123 """
124 import logging
125
126 logger = logging.getLogger(__name__)
127
128 def setup_function(function):
129 logger.info('text going to logger from setup')
130
131 def test_foo():
132 logger.info('text going to logger from call')
133 assert False
134 """
135 )
136 result = pytester.runpytest("--log-level=INFO")
137 assert result.ret == 1
138 result.stdout.fnmatch_lines(
139 [
140 "*- Captured *log setup -*",
141 "*text going to logger from setup*",
142 "*- Captured *log call -*",
143 "*text going to logger from call*",
144 ]
145 )
146
147
148def test_teardown_logging(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 3

fnmatch_linesMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected