Browse Source

Replace use of “exclude_path” in tests

The newly added pattern matcher class can replace the “exclude_path”
function. The latter is going to be removed in a later change.
Michael Hanselmann 9 years ago
parent
commit
190107ada7
1 changed files with 4 additions and 3 deletions
  1. 4 3
      borg/testsuite/helpers.py

+ 4 - 3
borg/testsuite/helpers.py

@@ -9,7 +9,7 @@ import sys
 import msgpack
 import msgpack
 import msgpack.fallback
 import msgpack.fallback
 
 
-from ..helpers import exclude_path, Location, format_file_size, format_timedelta, PathPrefixPattern, FnmatchPattern, make_path_safe, \
+from ..helpers import Location, format_file_size, format_timedelta, PathPrefixPattern, FnmatchPattern, make_path_safe, \
     prune_within, prune_split, get_cache_dir, Statistics, is_slow_msgpack, yes, RegexPattern, \
     prune_within, prune_split, get_cache_dir, Statistics, is_slow_msgpack, yes, RegexPattern, \
     StableDict, int_to_bigint, bigint_to_int, parse_timestamp, CompressionSpec, ChunkerParams, \
     StableDict, int_to_bigint, bigint_to_int, parse_timestamp, CompressionSpec, ChunkerParams, \
     ProgressIndicatorPercent, ProgressIndicatorEndless, load_excludes, parse_pattern, PatternMatcher
     ProgressIndicatorPercent, ProgressIndicatorEndless, load_excludes, parse_pattern, PatternMatcher
@@ -334,8 +334,9 @@ def test_patterns_from_file(tmpdir, lines, expected):
     ]
     ]
 
 
     def evaluate(filename):
     def evaluate(filename):
-        patterns = load_excludes(open(filename, "rt"))
-        return [path for path in files if not exclude_path(path, patterns)]
+        matcher = PatternMatcher(fallback=True)
+        matcher.add(load_excludes(open(filename, "rt")), False)
+        return [path for path in files if matcher.match(path)]
 
 
     exclfile = tmpdir.join("exclude.txt")
     exclfile = tmpdir.join("exclude.txt")