diff --git a/scrapemed/tests/test_trees.py b/scrapemed/tests/test_trees.py index b49dda9..69cd194 100644 --- a/scrapemed/tests/test_trees.py +++ b/scrapemed/tests/test_trees.py @@ -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 \ No newline at end of file diff --git a/scrapemed/trees.py b/scrapemed/trees.py index dfa4c10..f4205ba 100644 --- a/scrapemed/trees.py +++ b/scrapemed/trees.py @@ -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):