Test LineMatcher with regard to passing in a set (accidentally).
()
| 474 | |
| 475 | |
| 476 | def 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 | |
| 500 | def test_linematcher_match_failure() -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…