Skip to content

Commit

Permalink
fix graphviz test, remove render testing for GH
Browse files Browse the repository at this point in the history
  • Loading branch information
danielfrees committed Aug 18, 2023
1 parent a0edb33 commit 55812fe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion scrapemed/tests/test_trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_scrape():
assert trees._generate_tag_dictionary(test_root) == CORRECT_DATA_DICT

#simply test that the visualization function runs
trees.visualize_element_tree(test_root, title = 'data/test_text_vis.gv')
trees.visualize_element_tree(test_root, title = 'data/test_text_vis.gv', test_mode = True)
trees.investigate_xml_tree(test_root)

return None
5 changes: 3 additions & 2 deletions scrapemed/trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ def investigate_xml_tree(root: ET.Element)->None:
print("--------------------------------------------\n")
return

def visualize_element_tree(root: ET.Element, title = 'data/element_tree.gv')->None:
def visualize_element_tree(root: ET.Element, title = 'data/element_tree.gv', test_mode=False)->None:
"""Visualize an XML element tree using Graphviz."""
root = copy.copy(root)
dot = Digraph()
_add_elements(dot, root)
dot.render(title, view=True)
if not test_mode:
dot.render(title, view=True)
return

def _add_elements(dot: Digraph, element: ET.Element, parent=None):
Expand Down

0 comments on commit 55812fe

Please sign in to comment.