Skip to content

Commit a244330

Browse files
committed
fix unit test
Signed-off-by: Stephen L. <lrq3000@gmail.com>
1 parent f1b7b7e commit a244330

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

pyFileFixity/tests/test_replication_repair.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,18 @@ def setup_module():
2525

2626
def test_relpath_posix():
2727
""" repli: test internal: relpath_posix()"""
28-
recwalk_result = [r'C:\test\some\path', r'relative\path\file.ext']
29-
pardir = r'C:\test\some'
30-
print(rep.relpath_posix(recwalk_result, pardir, True))
31-
assert rep.relpath_posix(recwalk_result, pardir, True) == ('C:\\test\\some\\path', ['path', 'relative', 'path', 'file.ext'])
3228
recwalk_result = [r'/test/some/path', r'relative/path/file.ext']
3329
pardir = r'/test/some'
3430
assert rep.relpath_posix(recwalk_result, pardir, False) == ('/test/some/path', ['path', 'relative', 'path', 'file.ext'])
35-
recwalk_result = [r'/test/some/path', r'relative\path\file.ext']
36-
pardir = r'/test/some'
37-
assert rep.relpath_posix(recwalk_result, pardir, True) == ('/test/some/path', ['path', 'relative', 'path', 'file.ext'])
31+
32+
# Can only test the following on a Windows machine, because relpath_posix() uses os.path.relpath to remove the parent directory from the relative path, but Windows path delimiters aren't recognized on a Linux machine, and there's no way to specify the delimiter as an argument...
33+
if os.name == 'nt':
34+
recwalk_result = [r'C:\test\some\path', r'relative\path\file.ext']
35+
pardir = r'C:\test\some'
36+
assert rep.relpath_posix(recwalk_result, pardir, True) == ('C:\\test\\some\\path', ['path', 'relative', 'path', 'file.ext'])
37+
recwalk_result = [r'/test/some/path', r'relative\path\file.ext']
38+
pardir = r'/test/some'
39+
assert rep.relpath_posix(recwalk_result, pardir, True) == ('/test/some/path', ['path', 'relative', 'path', 'file.ext'])
3840

3941
def test_sort_dict_of_paths():
4042
d = {0: ['testoo.TXT'], 1: ['testoo.TXT'], 2: ['testbb-more.TXT'], 3: ['sub', 'testsub.TXT']}

0 commit comments

Comments
 (0)