MCPcopy
hub / github.com/pytest-dev/pytest / test_linematcher_match_failure

Function test_linematcher_match_failure

testing/test_pytester.py:500–525  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

498
499
500def test_linematcher_match_failure() -> None:
501 lm = LineMatcher(["foo", "foo", "bar"])
502 with pytest.raises(pytest.fail.Exception) as e:
503 lm.fnmatch_lines(["foo", "f*", "baz"])
504 assert e.value.msg is not None
505 assert e.value.msg.splitlines() == [
506 "exact match: 'foo'",
507 "fnmatch: 'f*'",
508 " with: 'foo'",
509 "nomatch: 'baz'",
510 " and: 'bar'",
511 "remains unmatched: 'baz'",
512 ]
513
514 lm = LineMatcher(["foo", "foo", "bar"])
515 with pytest.raises(pytest.fail.Exception) as e:
516 lm.re_match_lines(["foo", "^f.*", "baz"])
517 assert e.value.msg is not None
518 assert e.value.msg.splitlines() == [
519 "exact match: 'foo'",
520 "re.match: '^f.*'",
521 " with: 'foo'",
522 " nomatch: 'baz'",
523 " and: 'bar'",
524 "remains unmatched: 'baz'",
525 ]
526
527
528def 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