I have a unit test that I\'d like to write for a function that takes XML as a string. It\'s a doctest and I\'d like the XML in-line with the tests. Since the XML is multi-line
This code works, e.g. with Python 2.7.12 and 3.5.2:
def test():
"""
>>> config = '''<?xml version="1.0"?>
... <test>
... <data>d1</data>
... <data>d2</data>
... </test>'''
>>> print(config)
<?xml version="1.0"?>
<test>
<data>d1</data>
<data>d2</data>
</test>
"""
if __name__ == "__main__":
import doctest
doctest.testmod(name='test')