()
| 598 | |
| 599 | |
| 600 | def test_pattern_matcher(): |
| 601 | pm = PatternMatcher() |
| 602 | |
| 603 | assert pm.fallback is None |
| 604 | |
| 605 | for i in ["", "foo", "bar"]: |
| 606 | assert pm.match(i) is None |
| 607 | |
| 608 | # add extra entries to aid in testing |
| 609 | for target in ["A", "B", "Empty", "FileNotFound"]: |
| 610 | pm.is_include_cmd[target] = target |
| 611 | |
| 612 | pm.add([RegexPattern("^a")], "A") |
| 613 | pm.add([RegexPattern("^b"), RegexPattern("^z")], "B") |
| 614 | pm.add([RegexPattern("^$")], "Empty") |
| 615 | pm.fallback = "FileNotFound" |
| 616 | |
| 617 | assert pm.match("") == "Empty" |
| 618 | assert pm.match("aaa") == "A" |
| 619 | assert pm.match("bbb") == "B" |
| 620 | assert pm.match("ccc") == "FileNotFound" |
| 621 | assert pm.match("xyz") == "FileNotFound" |
| 622 | assert pm.match("z") == "B" |
| 623 | |
| 624 | assert PatternMatcher(fallback="hey!").fallback == "hey!" |
| 625 | |
| 626 | |
| 627 | @pytest.mark.parametrize( |
nothing calls this directly
no test coverage detected