Skip to content

Commit 94b41ba

Browse files
committed
Fix test cases for Windows environment
1 parent 0d83b84 commit 94b41ba

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

test/test_filepath.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import pytest
1212

1313
from pathvalidate import (
14+
ErrorReason,
1415
InvalidCharError,
1516
InvalidLengthError,
1617
NullNameError,
@@ -398,7 +399,6 @@ def test_exception(self, value, expected):
398399
assert not is_valid_filepath(value)
399400

400401

401-
@pytest.mark.skipif("m_platform.system() != 'Windows'")
402402
class Test_validate_win_file_path:
403403
VALID_CHARS = VALID_PATH_CHARS
404404

@@ -413,19 +413,20 @@ class Test_validate_win_file_path:
413413
["C:\\Users/est\\AppData/Local\\Temp/pytest-of-test\\pytest-0/hoge.csv"],
414414
["C:\\Users"],
415415
["C:\\"],
416-
["\\Users"],
417416
],
418417
)
419418
def test_normal(self, value):
420-
validate_filepath(value)
421-
assert is_valid_filepath(value)
419+
validate_filepath(value, platform="windows")
420+
assert is_valid_filepath(value, platform="windows")
422421

423422
@pytest.mark.parametrize(
424-
["value"], [["C:\\Users\\" + "a" * 1024]],
423+
["value", "expected"],
424+
[["C:\\Users\\" + "a" * 1024, InvalidCharError], ["\\Users", InvalidCharError]],
425425
)
426426
def test_exception(self, value, expected):
427-
with pytest.raises(expected):
427+
with pytest.raises(ValidationError) as e:
428428
validate_filepath(value)
429+
assert e.value.reason == ErrorReason.MALFORMED_ABS_PATH
429430
assert not is_valid_filepath(value)
430431

431432

0 commit comments

Comments
 (0)