8
8
from typing import Generator
9
9
10
10
import pytest
11
- from _pytest .compat import legacy_path
12
11
from _pytest .monkeypatch import MonkeyPatch
13
12
from _pytest .pathlib import bestrelpath
14
13
from _pytest .pathlib import commonpath
26
25
27
26
28
27
class TestFNMatcherPort :
29
- """Test that our port of py.common.FNMatcher (fnmatch_ex) produces the
30
- same results as the original legacy_path.fnmatch method."""
31
-
32
- @pytest .fixture (params = ["pathlib" , "py.path" ])
33
- def match (self , request ):
34
- if request .param == "py.path" :
35
-
36
- def match_ (pattern , path ):
37
- return legacy_path (path ).fnmatch (pattern )
38
-
39
- else :
40
- assert request .param == "pathlib"
41
-
42
- def match_ (pattern , path ):
43
- return fnmatch_ex (pattern , path )
44
-
45
- return match_
28
+ """Test our port of py.common.FNMatcher (fnmatch_ex)."""
46
29
47
30
if sys .platform == "win32" :
48
31
drv1 = "c:"
@@ -58,36 +41,36 @@ def match_(pattern, path):
58
41
("*.py" , "bar/foo.py" ),
59
42
("test_*.py" , "foo/test_foo.py" ),
60
43
("tests/*.py" , "tests/foo.py" ),
61
- (drv1 + " /*.py" , drv1 + " /foo.py" ),
62
- (drv1 + " /foo/*.py" , drv1 + " /foo/foo.py" ),
44
+ (f" { drv1 } /*.py" , f" { drv1 } /foo.py" ),
45
+ (f" { drv1 } /foo/*.py" , f" { drv1 } /foo/foo.py" ),
63
46
("tests/**/test*.py" , "tests/foo/test_foo.py" ),
64
47
("tests/**/doc/test*.py" , "tests/foo/bar/doc/test_foo.py" ),
65
48
("tests/**/doc/**/test*.py" , "tests/foo/doc/bar/test_foo.py" ),
66
49
],
67
50
)
68
- def test_matching (self , match , pattern , path ) :
69
- assert match (pattern , path )
51
+ def test_matching (self , pattern : str , path : str ) -> None :
52
+ assert fnmatch_ex (pattern , path )
70
53
71
- def test_matching_abspath (self , match ) :
54
+ def test_matching_abspath (self ) -> None :
72
55
abspath = os .path .abspath (os .path .join ("tests/foo.py" ))
73
- assert match ("tests/foo.py" , abspath )
56
+ assert fnmatch_ex ("tests/foo.py" , abspath )
74
57
75
58
@pytest .mark .parametrize (
76
59
"pattern, path" ,
77
60
[
78
61
("*.py" , "foo.pyc" ),
79
62
("*.py" , "foo/foo.pyc" ),
80
63
("tests/*.py" , "foo/foo.py" ),
81
- (drv1 + " /*.py" , drv2 + " /foo.py" ),
82
- (drv1 + " /foo/*.py" , drv2 + " /foo/foo.py" ),
64
+ (f" { drv1 } /*.py" , f" { drv2 } /foo.py" ),
65
+ (f" { drv1 } /foo/*.py" , f" { drv2 } /foo/foo.py" ),
83
66
("tests/**/test*.py" , "tests/foo.py" ),
84
67
("tests/**/test*.py" , "foo/test_foo.py" ),
85
68
("tests/**/doc/test*.py" , "tests/foo/bar/doc/foo.py" ),
86
69
("tests/**/doc/test*.py" , "tests/foo/bar/test_foo.py" ),
87
70
],
88
71
)
89
- def test_not_matching (self , match , pattern , path ) :
90
- assert not match (pattern , path )
72
+ def test_not_matching (self , pattern : str , path : str ) -> None :
73
+ assert not fnmatch_ex (pattern , path )
91
74
92
75
93
76
class TestImportPath :
0 commit comments