Skip to content

Commit

Permalink
Fix macro bug with empty CDATA being None instead of ''.
Browse files Browse the repository at this point in the history
Fixes galaxyproject/planemo#362 thanks for the report @erasche.

Test using the following command:

```
nosetests test/unit/tools/test_tool_loader.py
```
  • Loading branch information
jmchilton committed Nov 18, 2015
1 parent 73f46f4 commit 05f3da3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/galaxy/util/xml_macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def load(path):
_import_macros(root, path)

# Collect tokens
tokens = _macros_of_type(root, 'token', lambda el: el.text)
tokens = _macros_of_type(root, 'token', lambda el: el.text or '')

# Expand xml macros
macro_dict = _macros_of_type(root, 'xml', lambda el: XmlMacroDef(el))
Expand Down
16 changes: 16 additions & 0 deletions test/unit/tools/test_tool_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,22 @@ def load(self, name="tool.xml", preprocess=True):
value = tag_el.get('value')
assert value == "The value.", value

with TestToolDirectory() as tool_dir:
tool_dir.write('''
<tool>
<macros>
<token name="@TAG_VAL@"><![CDATA[]]></token>
</macros>
<another>
<tag value="@TAG_VAL@" />
</another>
</tool>
''')
xml = tool_dir.load()
tag_el = xml.find("another").find("tag")
value = tag_el.get('value')
assert value == "", value

# Test macros XML macros with $$ expansions in attributes
with TestToolDirectory() as tool_dir:
tool_dir.write('''
Expand Down

0 comments on commit 05f3da3

Please sign in to comment.