(function: str)
| 547 | |
| 548 | @pytest.mark.parametrize("function", ["no_fnmatch_line", "no_re_match_line"]) |
| 549 | def test_linematcher_no_matching(function: str) -> None: |
| 550 | if function == "no_fnmatch_line": |
| 551 | good_pattern = "*.py OK*" |
| 552 | bad_pattern = "*X.py OK*" |
| 553 | else: |
| 554 | assert function == "no_re_match_line" |
| 555 | good_pattern = r".*py OK" |
| 556 | bad_pattern = r".*Xpy OK" |
| 557 | |
| 558 | lm = LineMatcher( |
| 559 | [ |
| 560 | "cachedir: .pytest_cache", |
| 561 | "collecting ... collected 1 item", |
| 562 | "", |
| 563 | "show_fixtures_per_test.py OK", |
| 564 | "=== elapsed 1s ===", |
| 565 | ] |
| 566 | ) |
| 567 | |
| 568 | # check the function twice to ensure we don't accumulate the internal buffer |
| 569 | for i in range(2): |
| 570 | with pytest.raises(pytest.fail.Exception) as e: |
| 571 | func = getattr(lm, function) |
| 572 | func(good_pattern) |
| 573 | obtained = str(e.value).splitlines() |
| 574 | if function == "no_fnmatch_line": |
| 575 | assert obtained == [ |
| 576 | f"nomatch: '{good_pattern}'", |
| 577 | " and: 'cachedir: .pytest_cache'", |
| 578 | " and: 'collecting ... collected 1 item'", |
| 579 | " and: ''", |
| 580 | f"fnmatch: '{good_pattern}'", |
| 581 | " with: 'show_fixtures_per_test.py OK'", |
| 582 | ] |
| 583 | else: |
| 584 | assert obtained == [ |
| 585 | f" nomatch: '{good_pattern}'", |
| 586 | " and: 'cachedir: .pytest_cache'", |
| 587 | " and: 'collecting ... collected 1 item'", |
| 588 | " and: ''", |
| 589 | f"re.match: '{good_pattern}'", |
| 590 | " with: 'show_fixtures_per_test.py OK'", |
| 591 | ] |
| 592 | |
| 593 | func = getattr(lm, function) |
| 594 | func(bad_pattern) # bad pattern does not match any line: passes |
| 595 | |
| 596 | |
| 597 | def test_linematcher_no_matching_after_match() -> None: |
nothing calls this directly
no test coverage detected