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 8dfffa8
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("^{0}$".format(join("a", "b")))
self.config.add_exclusion_regex("^a{0}.+pyi$".format(os.path.sep)x)

# 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", "b"))

paths = ["a/code.py", "a/code.pyi", "a/b/code.py"]
paths = [
join("a", "code.py"),
join("a", "code.pyi"),
join("a", "b", "code.py"),
]
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, [join("a", "code.py")])

rmtree(tmp_fld)

Expand Down

0 comments on commit 8dfffa8

Please sign in to comment.