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

Function test_linematcher_with_nonlist

testing/test_pytester.py:476–497  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

474
475
476def test_linematcher_with_nonlist() -> None:
477 """Test LineMatcher with regard to passing in a set (accidentally)."""
478 from _pytest._code.source import Source
479
480 lm = LineMatcher([])
481 with pytest.raises(TypeError, match="invalid type for lines2: set"):
482 lm.fnmatch_lines(set()) # type: ignore[arg-type]
483 with pytest.raises(TypeError, match="invalid type for lines2: dict"):
484 lm.fnmatch_lines({}) # type: ignore[arg-type]
485 with pytest.raises(TypeError, match="invalid type for lines2: set"):
486 lm.re_match_lines(set()) # type: ignore[arg-type]
487 with pytest.raises(TypeError, match="invalid type for lines2: dict"):
488 lm.re_match_lines({}) # type: ignore[arg-type]
489 with pytest.raises(TypeError, match="invalid type for lines2: Source"):
490 lm.fnmatch_lines(Source()) # type: ignore[arg-type]
491 lm.fnmatch_lines([])
492 lm.fnmatch_lines(())
493 lm.fnmatch_lines("")
494 assert lm._getlines({}) == {} # type: ignore[arg-type,comparison-overlap]
495 assert lm._getlines(set()) == set() # type: ignore[arg-type,comparison-overlap]
496 assert lm._getlines(Source()) == []
497 assert lm._getlines(Source("pass\npass")) == ["pass", "pass"]
498
499
500def 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…