Skip to content

Commit 2bf9998

Browse files
committed
Add suggestions
1 parent cc48176 commit 2bf9998

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

tests/test_filer.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ def normalize_tree(tree_str, abs_root, prefix):
3232
"""Convert absolute paths from getTree into relative paths."""
3333
lines = []
3434
for line in tree_str.splitlines():
35-
stripped = line.replace(abs_root, prefix)
35+
if line.startswith(abs_root):
36+
stripped = prefix + line[len(abs_root):]
37+
else:
38+
stripped = line
3639
stripped = stripped.lstrip("/")
3740
lines.append(stripped)
3841
return "\n".join(lines)
@@ -166,7 +169,10 @@ def test_copyDir(self):
166169

167170
expected = "dist1\na/\n3.txt\ndist1/a\n2.txt\n1.txt".strip()
168171

169-
self.assertEqual(normalizedTree, expected)
172+
normalized_lines = sorted(normalizedTree.splitlines())
173+
expected_lines = sorted(expected.splitlines())
174+
175+
self.assertEqual(normalized_lines, expected_lines)
170176

171177
# Copying to non-existing dst -----------------------------------------
172178
# # Let's try to copy
@@ -177,7 +183,10 @@ def test_copyDir(self):
177183

178184
expected = "dist2\na/\n3.txt\ndist2/a\n2.txt\n1.txt".strip()
179185

180-
self.assertEqual(normalizedTree, expected)
186+
normalized_lines = sorted(normalizedTree.splitlines())
187+
expected_lines = sorted(expected.splitlines())
188+
189+
self.assertEqual(normalized_lines, expected_lines)
181190

182191
def test_getPath(self):
183192

0 commit comments

Comments
 (0)