Skip to content

Commit 7b46a03

Browse files
committed
Fix Windows regression
1 parent fdc0183 commit 7b46a03

3 files changed

Lines changed: 13 additions & 9 deletions

File tree

tests/test_01_util.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55
import errno
66
import os
77
import os.path
8-
import pathlib
98
import shutil
109
import tempfile
1110
import unittest
1211
from collections.abc import (
1312
Iterable)
1413
from functools import (
1514
partial)
15+
from pathlib import (
16+
Path,
17+
PurePath)
1618
from typing import (
1719
ClassVar,
1820
Optional) # Replaced by `X | None` in 3.10.
@@ -151,7 +153,7 @@ def setUp(self) -> None:
151153
"""
152154
Called before each test.
153155
"""
154-
self.temp_dir = pathlib.Path(tempfile.mkdtemp())
156+
self.temp_dir = Path(tempfile.mkdtemp())
155157

156158
def tearDown(self) -> None:
157159
"""
@@ -701,8 +703,8 @@ class NormalizeFileTest(unittest.TestCase):
701703

702704
def test_01_purepath(self):
703705
"""
704-
Tests normalizing a :class:`pathlib.PurePath` as argument.
706+
Tests normalizing a :class:`PurePath` as argument.
705707
"""
706-
first_spec = normalize_file(pathlib.PurePath('a.txt'))
708+
first_spec = normalize_file(PurePath('a.txt'))
707709
second_spec = normalize_file('a.txt')
708710
self.assertEqual(first_spec, second_spec)

tests/test_03_pathspec.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -676,14 +676,14 @@ def test_05_match_tree_entries(self):
676676
'!b.txt',
677677
]):
678678
with sub_test() as spec:
679-
files = {
679+
files = set(map(ospath, [
680680
'X/a.txt',
681681
'X/b.txt',
682682
'X/Z/c.txt',
683683
'Y/a.txt',
684684
'Y/b.txt',
685685
'Y/Z/c.txt',
686-
}
686+
]))
687687

688688
self.make_dirs([
689689
'X',
@@ -713,14 +713,14 @@ def test_05_match_tree_files(self):
713713
'!b.txt',
714714
]):
715715
with sub_test() as spec:
716-
files = {
716+
files = set(map(ospath, [
717717
'X/a.txt',
718718
'X/b.txt',
719719
'X/Z/c.txt',
720720
'Y/a.txt',
721721
'Y/b.txt',
722722
'Y/Z/c.txt',
723-
}
723+
]))
724724

725725
self.make_dirs([
726726
'X',

tests/util.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ def debug_includes(spec: PathSpec, files: set[str], includes: set[str]) -> str:
4949
"""
5050
results = []
5151
for result in spec.check_files(files):
52-
assert (ospath(result.file) in includes) == bool(result.include), (result, includes)
52+
assert (result.file in includes) == bool(result.include), {
53+
'result': result, 'includes': includes,
54+
}
5355
results.append(result)
5456

5557
return debug_results(spec, results)

0 commit comments

Comments
 (0)