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

Function test_linematcher_with_nonlist

testing/test_pytester.py:486–507  ·  view source on GitHub ↗

Test LineMatcher with regard to passing in a set (accidentally).

()

Source from the content-addressed store, hash-verified

484
485
486def test_linematcher_with_nonlist() -> None:
487 """Test LineMatcher with regard to passing in a set (accidentally)."""
488 from _pytest._code.source import Source
489
490 lm = LineMatcher([])
491 with pytest.raises(TypeError, match="invalid type for lines2: set"):
492 lm.fnmatch_lines(set()) # type: ignore[arg-type]
493 with pytest.raises(TypeError, match="invalid type for lines2: dict"):
494 lm.fnmatch_lines({}) # type: ignore[arg-type]
495 with pytest.raises(TypeError, match="invalid type for lines2: set"):
496 lm.re_match_lines(set()) # type: ignore[arg-type]
497 with pytest.raises(TypeError, match="invalid type for lines2: dict"):
498 lm.re_match_lines({}) # type: ignore[arg-type]
499 with pytest.raises(TypeError, match="invalid type for lines2: Source"):
500 lm.fnmatch_lines(Source()) # type: ignore[arg-type]
501 lm.fnmatch_lines([])
502 lm.fnmatch_lines(())
503 lm.fnmatch_lines("")
504 assert lm._getlines({}) == {} # type: ignore[arg-type,comparison-overlap]
505 assert lm._getlines(set()) == set() # type: ignore[arg-type,comparison-overlap]
506 assert lm._getlines(Source()) == []
507 assert lm._getlines(Source("pass\npass")) == ["pass", "pass"]
508
509
510def test_linematcher_match_failure() -> None:

Callers

nothing calls this directly

Calls 5

fnmatch_linesMethod · 0.95
re_match_linesMethod · 0.95
_getlinesMethod · 0.95
LineMatcherClass · 0.90
SourceClass · 0.90

Tested by

no test coverage detected