Skip to content

Commit acf56c0

Browse files
committed
Escape filenames which looks like regexp
1 parent e391fbe commit acf56c0

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Diff for: relint.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def main():
188188
paths = {
189189
path
190190
for file in args.files
191-
for path in glob.iglob(file, recursive=True)
191+
for path in glob.iglob(glob.escape(file), recursive=True)
192192
}
193193

194194
tests = list(load_config(args.config))

Diff for: test_relint.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88

99

1010
class TestMain:
11-
def test_main_execution(self, mocker):
12-
mocker.patch.object(sys, 'argv', ['relint.py', 'test_relint.py'])
11+
@pytest.mark.parametrize('filename', ['test_relint.py', '[a-b].py', '[b-a].py'])
12+
def test_main_execution(self, mocker, filename):
13+
mocker.patch.object(sys, 'argv', ['relint.py', filename])
1314

1415
with pytest.raises(SystemExit) as exc_info:
1516
main()

0 commit comments

Comments
 (0)