Test LineMatcher with regard to passing in a set (accidentally).
()
| 484 | |
| 485 | |
| 486 | def 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 | |
| 510 | def test_linematcher_match_failure() -> None: |
nothing calls this directly
no test coverage detected