MCPcopy
hub / github.com/borgbackup/borg / test_inclexcl_patterns_from_file

Function test_inclexcl_patterns_from_file

src/borg/testsuite/patterns_test.py:533–558  ·  view source on GitHub ↗
(tmpdir, lines, expected)

Source from the content-addressed store, hash-verified

531 ],
532)
533def test_inclexcl_patterns_from_file(tmpdir, lines, expected):
534 files = [
535 "data",
536 "data/something00.txt",
537 "data/subdir/something01.txt",
538 "home",
539 "home/leo",
540 "home/leo/t",
541 "home/other",
542 ]
543
544 def evaluate(filename):
545 matcher = PatternMatcher(fallback=True)
546 roots = []
547 inclexclpatterns = []
548 with open(filename) as f:
549 load_pattern_file(f, roots, inclexclpatterns)
550 matcher.add_inclexcl(inclexclpatterns)
551 return [path for path in files if matcher.match(path)]
552
553 patternfile = tmpdir.join("patterns.txt")
554
555 with patternfile.open("wt") as fh:
556 fh.write("\n".join(lines))
557
558 assert evaluate(str(patternfile)) == (files if expected is None else expected)
559
560
561@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 3

evaluateFunction · 0.85
openMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected