Skip to content

Commit

Permalink
fix unit test
Browse files Browse the repository at this point in the history
use galaxy.util.xml_to_string for export since lxml is not always
available?
  • Loading branch information
bernt-matthias committed Jan 12, 2022
1 parent 8ba6795 commit 0dfcf48
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions lib/galaxy/util/xml_macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ def _expand_yield_statements(macro_def, expand_el):
Modifies the macro_def element by replacing all <yield/> tags below the
macro_def element by the children of the expand_el
>>> from lxml.etree import tostring
>>> from galaxy.util import XML
>>> from galaxy.util import XML, xml_to_string
>>> expand_el = XML('''
... <expand macro="test">
... <sub_of_expand_1/>
Expand All @@ -172,12 +171,15 @@ def _expand_yield_statements(macro_def, expand_el):
... <B><yield/></B>
... </xml>''')
>>> _expand_yield_statements(macro_def, expand_el)
>>> print(tostring(macro_def).decode('UTF-8'))
>>> print(xml_to_string(macro_def, pretty=True))
<?xml version="1.0" ?>
<xml name="test">
<A><sub_of_expand_1/>
<A>
<sub_of_expand_1/>
<sub_of_expand_2/>
</A>
<B><sub_of_expand_1/>
<B>
<sub_of_expand_1/>
<sub_of_expand_2/>
</B>
</xml>
Expand All @@ -189,15 +191,16 @@ def _expand_yield_statements(macro_def, expand_el):
... <yield/>
... </xml>''')
>>> _expand_yield_statements(macro_def, expand_el)
>>> print(tostring(macro_def).decode('UTF-8'))
>>> print(xml_to_string(macro_def, pretty=True))
<?xml version="1.0" ?>
<xml name="test">
<blah/>
<sub_of_expand_1/>
<sub_of_expand_2/>
<sub_of_expand_2/>
<blah/>
<sub_of_expand_1/>
<sub_of_expand_2/>
</xml>
<sub_of_expand_2/>
</xml>
"""
yield_els = [yield_el for yield_el in macro_def.findall('.//yield')]
expand_el_children = list(expand_el)
Expand Down

0 comments on commit 0dfcf48

Please sign in to comment.