|
|
@@ -275,7 +275,8 @@ def test_exclude_patterns_from_file(tmpdir, lines, expected):
|
|
|
|
|
|
def evaluate(filename):
|
|
|
patterns = []
|
|
|
- load_exclude_file(open(filename), patterns)
|
|
|
+ with open(filename) as fh:
|
|
|
+ load_exclude_file(fh, patterns)
|
|
|
matcher = PatternMatcher(fallback=True)
|
|
|
matcher.add_inclexcl(patterns)
|
|
|
return [path for path in files if matcher.match(path)]
|
|
|
@@ -306,7 +307,8 @@ def test_load_patterns_from_file(tmpdir, lines, expected_roots, expected_numpatt
|
|
|
def evaluate(filename):
|
|
|
roots = []
|
|
|
inclexclpatterns = []
|
|
|
- load_pattern_file(open(filename), roots, inclexclpatterns)
|
|
|
+ with open(filename) as fh:
|
|
|
+ load_pattern_file(fh, roots, inclexclpatterns)
|
|
|
return roots, len(inclexclpatterns)
|
|
|
patternfile = tmpdir.join("patterns.txt")
|
|
|
|
|
|
@@ -356,7 +358,8 @@ def test_load_invalid_patterns_from_file(tmpdir, lines):
|
|
|
with pytest.raises(argparse.ArgumentTypeError):
|
|
|
roots = []
|
|
|
inclexclpatterns = []
|
|
|
- load_pattern_file(open(filename), roots, inclexclpatterns)
|
|
|
+ with open(filename) as fh:
|
|
|
+ load_pattern_file(fh, roots, inclexclpatterns)
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize("lines, expected", [
|
|
|
@@ -400,7 +403,8 @@ def test_inclexcl_patterns_from_file(tmpdir, lines, expected):
|
|
|
matcher = PatternMatcher(fallback=True)
|
|
|
roots = []
|
|
|
inclexclpatterns = []
|
|
|
- load_pattern_file(open(filename), roots, inclexclpatterns)
|
|
|
+ with open(filename) as fh:
|
|
|
+ load_pattern_file(fh, roots, inclexclpatterns)
|
|
|
matcher.add_inclexcl(inclexclpatterns)
|
|
|
return [path for path in files if matcher.match(path)]
|
|
|
|