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

Function test_linematcher_match_failure

testing/test_pytester.py:510–535  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

508
509
510def test_linematcher_match_failure() -> None:
511 lm = LineMatcher(["foo", "foo", "bar"])
512 with pytest.raises(pytest.fail.Exception) as e:
513 lm.fnmatch_lines(["foo", "f*", "baz"])
514 assert e.value.msg is not None
515 assert e.value.msg.splitlines() == [
516 "exact match: 'foo'",
517 "fnmatch: 'f*'",
518 " with: 'foo'",
519 "nomatch: 'baz'",
520 " and: 'bar'",
521 "remains unmatched: 'baz'",
522 ]
523
524 lm = LineMatcher(["foo", "foo", "bar"])
525 with pytest.raises(pytest.fail.Exception) as e:
526 lm.re_match_lines(["foo", "^f.*", "baz"])
527 assert e.value.msg is not None
528 assert e.value.msg.splitlines() == [
529 "exact match: 'foo'",
530 "re.match: '^f.*'",
531 " with: 'foo'",
532 " nomatch: 'baz'",
533 " and: 'bar'",
534 "remains unmatched: 'baz'",
535 ]
536
537
538def test_linematcher_consecutive() -> None:

Callers

nothing calls this directly

Calls 3

fnmatch_linesMethod · 0.95
re_match_linesMethod · 0.95
LineMatcherClass · 0.90

Tested by

no test coverage detected