Filters defined in the command-line should take precedence over filters in ini files (#3946).
(
pytester: Pytester, ignore_on_cmdline
)
| 383 | |
| 384 | @pytest.mark.parametrize("ignore_on_cmdline", [True, False]) |
| 385 | def 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 | |
| 410 | def test_option_precedence_mark(pytester: Pytester) -> None: |
nothing calls this directly
no test coverage detected