Message212025
Martin, the exact information you need are:
1. this is what I did:
#!/usr/bin/env python
import unittest
import xmlrunner
class Foo(unittest.TestCase):
def testFoo(self):
self.assertTrue(False, ']]>')
unittest.main(testRunner=xmlrunner.XMLTestRunner(output='test-reports'))
2. this is what happened:
arturcz@szczaw:/tmp$ ./cdata.py
Running tests...
----------------------------------------------------------------------
F
======================================================================
FAIL [0.000s]: testFoo (__main__.Foo)
----------------------------------------------------------------------
Traceback (most recent call last):
File "./cdata.py", line 7, in testFoo
self.assertTrue(False, ']]>')
AssertionError: ]]>
----------------------------------------------------------------------
Ran 1 test in 0.001s
FAILED (failures=1)
Generating XML reports...
Traceback (most recent call last):
File "./cdata.py", line 9, in <module>
unittest.main(testRunner=xmlrunner.XMLTestRunner(output='test-reports'))
File "/usr/lib/python2.7/unittest/main.py", line 95, in __init__
self.runTests()
File "/usr/lib/python2.7/unittest/main.py", line 232, in runTests
self.result = testRunner.run(self.test)
File "/usr/lib/python2.7/dist-packages/xmlrunner/__init__.py", line 415, in run
result.generate_reports(self)
File "/usr/lib/python2.7/dist-packages/xmlrunner/__init__.py", line 312, in generate_reports
xml_content = doc.toprettyxml(indent='\t')
File "/usr/lib/python2.7/xml/dom/minidom.py", line 58, in toprettyxml
self.writexml(writer, "", indent, newl, encoding)
File "/usr/lib/python2.7/xml/dom/minidom.py", line 1749, in writexml
node.writexml(writer, indent, addindent, newl)
File "/usr/lib/python2.7/xml/dom/minidom.py", line 814, in writexml
node.writexml(writer, indent+addindent, addindent, newl)
File "/usr/lib/python2.7/xml/dom/minidom.py", line 814, in writexml
node.writexml(writer, indent+addindent, addindent, newl)
File "/usr/lib/python2.7/xml/dom/minidom.py", line 814, in writexml
node.writexml(writer, indent+addindent, addindent, newl)
File "/usr/lib/python2.7/xml/dom/minidom.py", line 1150, in writexml
raise ValueError("']]>' not allowed in a CDATA section")
ValueError: ']]>' not allowed in a CDATA section
and empty directory test-reports has been created.
3. this is what should have happened instead:
arturcz@szczaw:/tmp$ ./cdata.py
Running tests...
----------------------------------------------------------------------
F
======================================================================
FAIL [0.000s]: testFoo (__main__.Foo)
----------------------------------------------------------------------
Traceback (most recent call last):
File "./cdata.py", line 7, in testFoo
self.assertTrue(False, ']]>')
AssertionError: ]]>
----------------------------------------------------------------------
Ran 1 test in 0.001s
FAILED (failures=1)
Generating XML reports...
and file test-reports/TEST-Foo-${timestamp}.xml is created with following content:
<?xml version="1.0" ?>
<testsuite errors="0" failures="1" name="Foo-20140223203423" tests="1" time="0.000">
<testcase classname="Foo" name="testFoo" time="0.000">
<failure message="]]>" type="AssertionError">
<![CDATA[Traceback (most recent call last):
File "./cdata.py", line 7, in testFoo
self.assertTrue(False, ']]]]><![CDATA[>')
AssertionError: ]]]]><![CDATA[>
]]> </failure>
</testcase>
<system-out>
<![CDATA[]]> </system-out>
<system-err>
<![CDATA[]]> </system-err>
</testsuite>
however, on the level of minidom.py module, there is an exact test provided in attached repository.
PS. I removed the patch by purpose - it's wrong and someone could be misleaded by it. The correct solution I propose is in the attached repository. |
|
Date |
User |
Action |
Args |
2014-02-23 20:08:49 | arturcz | set | recipients:
+ arturcz, loewis, peter.otten, eric.araujo, serhiy.storchaka |
2014-02-23 20:08:49 | arturcz | set | messageid: <1393186129.21.0.629445846761.issue20714@psf.upfronthosting.co.za> |
2014-02-23 20:08:49 | arturcz | link | issue20714 messages |
2014-02-23 20:08:48 | arturcz | create | |
|