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

Function test_option_precedence_cmdline_over_ini

testing/test_warnings.py:385–407  ·  view source on GitHub ↗

Filters defined in the command-line should take precedence over filters in ini files (#3946).

(
    pytester: Pytester, ignore_on_cmdline
)

Source from the content-addressed store, hash-verified

383
384@pytest.mark.parametrize("ignore_on_cmdline", [True, False])
385def test_option_precedence_cmdline_over_ini(
386 pytester: Pytester, ignore_on_cmdline
387) -> None:
388 """Filters defined in the command-line should take precedence over filters in ini files (#3946)."""
389 pytester.makeini(
390 """
391 [pytest]
392 filterwarnings = error::UserWarning
393 """
394 )
395 pytester.makepyfile(
396 """
397 import warnings
398 def test():
399 warnings.warn(UserWarning('hello'))
400 """
401 )
402 args = ["-W", "ignore"] if ignore_on_cmdline else []
403 result = pytester.runpytest(*args)
404 if ignore_on_cmdline:
405 result.stdout.fnmatch_lines(["* 1 passed in*"])
406 else:
407 result.stdout.fnmatch_lines(["* 1 failed in*"])
408
409
410def test_option_precedence_mark(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 4

fnmatch_linesMethod · 0.80
makeiniMethod · 0.45
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected