Skip to content

Commit

Permalink
fix os path sep for regex on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmicexplorer committed Oct 8, 2022
1 parent d8726ec commit 661738f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tests/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,14 +359,18 @@ def test_exclude_regex_relative(self):

# Keep paths relative, and provide patterns matching relative paths.
self.config.set_make_paths_absolute(False)
self.config.add_exclusion_regex("^a/b$")
self.config.add_exclusion_regex(r"^a/[^/]+\.pyi$")
self.config.add_exclusion_regex("^a{0}b$".format(os.path.sep))
self.config.add_exclusion_regex(r"^a{0}[^{0}]+\.pyi$".format(os.path.sep))

# Create .../a and .../a/b directories.
os.mkdir(join(tmp_fld, "a"))
os.mkdir(join(tmp_fld, "a/b"))
os.mkdir(join(tmp_fld, "a{0}b".format(os.path.sep)))

paths = ["a/code.py", "a/code.pyi", "a/b/code.py"]
paths = [
"a{0}code.py".format(os.path.sep),
"a{0}code.pyi".format(os.path.sep),
"a{0}b{0}code.py".format(os.path.sep),
]
for p in paths:
f = touch(tmp_fld, p)
with open_wrapper(f, mode="w", encoding="utf-8") as fp:
Expand All @@ -375,7 +379,7 @@ def test_exclude_regex_relative(self):
# Temporarily modify the working directory.
with working_dir(tmp_fld):
paths = detect_paths(["a"], config=self.config)
self.assertEqual(paths, ["a/code.py"])
self.assertEqual(paths, ["a{0}code.py".format(os.path.sep)])

rmtree(tmp_fld)

Expand Down

0 comments on commit 661738f

Please sign in to comment.