Skip to content

Commit

Permalink
fix unit test
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen L. <[email protected]>
  • Loading branch information
lrq3000 committed Dec 7, 2015
1 parent f1b7b7e commit a244330
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions pyFileFixity/tests/test_replication_repair.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,18 @@ def setup_module():

def test_relpath_posix():
""" repli: test internal: relpath_posix()"""
recwalk_result = [r'C:\test\some\path', r'relative\path\file.ext']
pardir = r'C:\test\some'
print(rep.relpath_posix(recwalk_result, pardir, True))
assert rep.relpath_posix(recwalk_result, pardir, True) == ('C:\\test\\some\\path', ['path', 'relative', 'path', 'file.ext'])
recwalk_result = [r'/test/some/path', r'relative/path/file.ext']
pardir = r'/test/some'
assert rep.relpath_posix(recwalk_result, pardir, False) == ('/test/some/path', ['path', 'relative', 'path', 'file.ext'])
recwalk_result = [r'/test/some/path', r'relative\path\file.ext']
pardir = r'/test/some'
assert rep.relpath_posix(recwalk_result, pardir, True) == ('/test/some/path', ['path', 'relative', 'path', 'file.ext'])

# 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...
if os.name == 'nt':
recwalk_result = [r'C:\test\some\path', r'relative\path\file.ext']
pardir = r'C:\test\some'
assert rep.relpath_posix(recwalk_result, pardir, True) == ('C:\\test\\some\\path', ['path', 'relative', 'path', 'file.ext'])
recwalk_result = [r'/test/some/path', r'relative\path\file.ext']
pardir = r'/test/some'
assert rep.relpath_posix(recwalk_result, pardir, True) == ('/test/some/path', ['path', 'relative', 'path', 'file.ext'])

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

0 comments on commit a244330

Please sign in to comment.