MCPcopy Index your code
hub / github.com/borgbackup/borg / test_pattern_matcher

Function test_pattern_matcher

src/borg/testsuite/patterns_test.py:600–624  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

598
599
600def 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(

Callers

nothing calls this directly

Calls 4

matchMethod · 0.95
addMethod · 0.95
PatternMatcherClass · 0.85
RegexPatternClass · 0.85

Tested by

no test coverage detected