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

Function pytest_addoption

src/_pytest/logging.py:209–292  ·  view source on GitHub ↗

Add options to control log capturing.

(parser: Parser)

Source from the content-addressed store, hash-verified

207
208
209def pytest_addoption(parser: Parser) -> None:
210 """Add options to control log capturing."""
211 group = parser.getgroup("logging")
212
213 def add_option_ini(option, dest, default=None, type=None, **kwargs):
214 parser.addini(
215 dest, default=default, type=type, help="default value for " + option
216 )
217 group.addoption(option, dest=dest, **kwargs)
218
219 add_option_ini(
220 "--log-level",
221 dest="log_level",
222 default=None,
223 metavar="LEVEL",
224 help=(
225 "level of messages to catch/display.\n"
226 "Not set by default, so it depends on the root/parent log handler's"
227 ' effective level, where it is "WARNING" by default.'
228 ),
229 )
230 add_option_ini(
231 "--log-format",
232 dest="log_format",
233 default=DEFAULT_LOG_FORMAT,
234 help="log format as used by the logging module.",
235 )
236 add_option_ini(
237 "--log-date-format",
238 dest="log_date_format",
239 default=DEFAULT_LOG_DATE_FORMAT,
240 help="log date format as used by the logging module.",
241 )
242 parser.addini(
243 "log_cli",
244 default=False,
245 type="bool",
246 help='enable log display during test run (also known as "live logging").',
247 )
248 add_option_ini(
249 "--log-cli-level", dest="log_cli_level", default=None, help="cli logging level."
250 )
251 add_option_ini(
252 "--log-cli-format",
253 dest="log_cli_format",
254 default=None,
255 help="log format as used by the logging module.",
256 )
257 add_option_ini(
258 "--log-cli-date-format",
259 dest="log_cli_date_format",
260 default=None,
261 help="log date format as used by the logging module.",
262 )
263 add_option_ini(
264 "--log-file",
265 dest="log_file",
266 default=None,

Callers

nothing calls this directly

Calls 3

add_option_iniFunction · 0.85
getgroupMethod · 0.80
addiniMethod · 0.80

Tested by

no test coverage detected