Skip to content

Commit

Permalink
Merge pull request #34 from LucasAndradeDias/update-display-2
Browse files Browse the repository at this point in the history
Added numerical order
  • Loading branch information
LucasAndradeDias authored Oct 5, 2023
2 parents 4cd7fd7 + 0c1c5d6 commit a9d1a80
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/outliner/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def tree(self):
connect_branch = (
lines
+ self.ansi_for_tree["CHILD_OBJECT_ANSI"]
+ f"{position}. "
+ i
+ "\n"
+ self.ansi_for_tree["RESET"]
Expand All @@ -44,7 +45,11 @@ def tree(self):
connector_display = connector_root if position == 0 else connect_branch

sys.stdout.write(connector_display)
sys.stdout.write(str(" " + self.ansi_for_tree["VERTICAL_LINE"] + "\n"))

if position == (len(self.functions_flow) - 1):
return

sys.stdout.write(str(" " + self.ansi_for_tree["VERTICAL_LINE"]))
sys.stdout.flush()
position += 1

Expand Down
2 changes: 1 addition & 1 deletion tests/test_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def setUp(self):

@patch("sys.stdout", new_callable=StringIO)
def test_display_tree_positive_input(self, stdout):
expected_result = " \x1b[38;5;208mtest2\x1b[0m\n\n\n │──\x1b[36m__init__\n\x1b[0m │\n\n │──\x1b[36mfunc1\n\x1b[0m │\n\n │──\x1b[36mfunc2\n\x1b[0m\n"
expected_result = " \x1b[38;5;208mtest2\x1b[0m\n\n │──\x1b[36m1. __init__\n\x1b[0m │\n │──\x1b[36m2. func1\n\x1b[0m │\n │──\x1b[36m3. func2\n\x1b[0m"
self.parser.tree()
self.assertEqual(stdout.getvalue(), expected_result)

Expand Down

0 comments on commit a9d1a80

Please sign in to comment.