(pytester: Pytester)
| 411 | |
| 412 | |
| 413 | def test_match_raises_error(pytester: Pytester) -> None: |
| 414 | pytester.makepyfile( |
| 415 | """ |
| 416 | import pytest |
| 417 | def test_division_zero(): |
| 418 | with pytest.raises(ZeroDivisionError) as excinfo: |
| 419 | 0 / 0 |
| 420 | excinfo.match(r'[123]+') |
| 421 | """ |
| 422 | ) |
| 423 | result = pytester.runpytest() |
| 424 | assert result.ret != 0 |
| 425 | |
| 426 | exc_msg = "Regex pattern '[[]123[]]+' does not match 'division by zero'." |
| 427 | result.stdout.fnmatch_lines([f"E * AssertionError: {exc_msg}"]) |
| 428 | result.stdout.no_fnmatch_line("*__tracebackhide__ = True*") |
| 429 | |
| 430 | result = pytester.runpytest("--fulltrace") |
| 431 | assert result.ret != 0 |
| 432 | result.stdout.fnmatch_lines( |
| 433 | ["*__tracebackhide__ = True*", f"E * AssertionError: {exc_msg}"] |
| 434 | ) |
| 435 | |
| 436 | |
| 437 | class TestFormattedExcinfo: |
nothing calls this directly
no test coverage detected