34
34
sort_paths ,
35
35
traverse_to_file
36
36
)
37
- from domdf_python_tools .testing import not_pypy , not_windows
37
+ from domdf_python_tools .testing import not_pypy , not_windows , only_windows
38
38
39
39
40
40
def test_maybe_make (tmp_pathplus ):
@@ -161,7 +161,7 @@ def test_parent_path(tmp_pathplus):
161
161
assert str (paths .parent_path ("spam/spam/spam" )) == os .path .join ("spam" , "spam" )
162
162
163
163
164
- @not_windows ("Needs special-casing for Windows " )
164
+ @not_windows ("Windows uses a different path structure. " )
165
165
@pytest .mark .parametrize (
166
166
"relto, relpath" ,
167
167
[
@@ -178,6 +178,26 @@ def test_relpath(relto, relpath):
178
178
assert isinstance (paths .relpath (path , relative_to = relto ), pathlib .Path )
179
179
180
180
181
+ @only_windows ("Windows uses a different path structure." )
182
+ @pytest .mark .parametrize (
183
+ "relto, relpath" ,
184
+ [
185
+ ("c:/users/username/Documents/games/chess.py" , "c:/users/username/Documents/letter.doc" ),
186
+ ("c:/users/username/Documents" , "letter.doc" ),
187
+ (
188
+ pathlib .Path ("c:/users/username/Documents/games/chess.py" ),
189
+ "c:/users/username/Documents/letter.doc"
190
+ ),
191
+ (pathlib .Path ("c:/users/username/Documents" ), "letter.doc" ),
192
+ (None , pathlib .Path ("c:/users/username/Documents/letter.doc" )),
193
+ ],
194
+ )
195
+ def test_relpath_windows (relto , relpath ):
196
+ path = "c:/users/username/Documents/letter.doc"
197
+ assert paths .relpath (path , relative_to = relto ) == pathlib .Path (relpath )
198
+ assert isinstance (paths .relpath (path , relative_to = relto ), pathlib .Path )
199
+
200
+
181
201
class TestCurrentDirOperations :
182
202
183
203
def test_append (self ):
0 commit comments