Skip to content

Commit

Permalink
fix: unify_tree_symbols for windows ci e2e single file & empty folder…
Browse files Browse the repository at this point in the history
… tests
  • Loading branch information
bionicles committed Dec 24, 2023
1 parent d0461ec commit 7335947
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions tests/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,22 @@
"""


def unify_tree_symbols(tree_string):
if platform.system() == "Windows":
# Map Windows tree symbols to Unix/MacOS tree symbols
tree_string = tree_string.replace("\u2523", "\u251C") # '┣' in Ubuntu/MacOS
tree_string = tree_string.replace("\u2503", "\u2502") # '┃' in Ubuntu/MacOS
tree_string = tree_string.replace("\u2517", "\u2514") # '┗' in Ubuntu/MacOS
tree_string = tree_string.replace("\u2501", "\u2500") # '━' in Ubuntu/MacOS
return tree_string


def test_e2e_single_file():
result = tree_plus(f"{test_directory}/file.py")
assert isinstance(result, rich.tree.Tree)
result_str = tree_to_string(result)
print(result_str)
assert result_str == EXPECTATION_0
assert unify_tree_symbols(result_str) == EXPECTATION_0


EXPECTATION_EMPTY = """📁 empty_folder (0 tokens, 0 lines)
Expand All @@ -44,17 +54,7 @@ def test_e2e_empty_folder():
assert isinstance(result, rich.tree.Tree)
result_str = tree_to_string(result)
print(result_str)
assert result_str == EXPECTATION_EMPTY


def unify_tree_symbols(tree_string):
if platform.system() == "Windows":
# Map Windows tree symbols to Unix/MacOS tree symbols
tree_string = tree_string.replace("\u2523", "\u251C") # '┣' in Ubuntu/MacOS
tree_string = tree_string.replace("\u2503", "\u2502") # '┃' in Ubuntu/MacOS
tree_string = tree_string.replace("\u2517", "\u2514") # '┗' in Ubuntu/MacOS
tree_string = tree_string.replace("\u2501", "\u2500") # '━' in Ubuntu/MacOS
return tree_string
assert unify_tree_symbols(result_str) == EXPECTATION_EMPTY


EXPECTATION_1 = """📁 path_to_test (277 tokens, 66 lines)
Expand Down

0 comments on commit 7335947

Please sign in to comment.