File tree Expand file tree Collapse file tree 2 files changed +4
-7
lines changed Expand file tree Collapse file tree 2 files changed +4
-7
lines changed Original file line number Diff line number Diff line change 37
37
from _pytest .config .argparsing import Parser
38
38
from _pytest .fixtures import FixtureManager
39
39
from _pytest .outcomes import exit
40
+ from _pytest .pathlib import _is_same
40
41
from _pytest .pathlib import absolutepath
41
42
from _pytest .pathlib import bestrelpath
42
43
from _pytest .pathlib import fnmatch_ex
@@ -900,11 +901,7 @@ def collect(self) -> Iterator[Union[nodes.Item, nodes.Collector]]:
900
901
for node in reversed (subnodes ):
901
902
# Path part e.g. `/a/b/` in `/a/b/test_file.py::TestIt::test_it`.
902
903
if isinstance (matchparts [0 ], Path ):
903
- is_match = node .path == matchparts [0 ]
904
- if sys .platform == "win32" and not is_match :
905
- # In case the file paths do not match, fallback to samefile() to
906
- # account for short-paths on Windows (#11895).
907
- is_match = os .path .samefile (node .path , matchparts [0 ])
904
+ is_match = _is_same (node .path , matchparts [0 ])
908
905
# Name part e.g. `TestIt` in `/a/b/test_file.py::TestIt::test_it`.
909
906
else :
910
907
# TODO: Remove parametrized workaround once collection structure contains
Original file line number Diff line number Diff line change @@ -596,12 +596,12 @@ def import_path(
596
596
# compare equal, to circumvent os.path.samefile returning False for mounts in UNC (#7678).
597
597
if sys .platform .startswith ("win" ):
598
598
599
- def _is_same (f1 : str , f2 : str ) -> bool :
599
+ def _is_same (f1 : Union [ Path , str ] , f2 : Union [ Path , str ] ) -> bool :
600
600
return Path (f1 ) == Path (f2 ) or os .path .samefile (f1 , f2 )
601
601
602
602
else :
603
603
604
- def _is_same (f1 : str , f2 : str ) -> bool :
604
+ def _is_same (f1 : Union [ Path , str ] , f2 : Union [ Path , str ] ) -> bool :
605
605
return os .path .samefile (f1 , f2 )
606
606
607
607
You can’t perform that action at this time.
0 commit comments