You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import unittest
import xmlrunner
class ExampleTestCase(unittest.TestCase):
@unittest.expectedFailure
def test_unexpected_success(self):
self.assertTrue(True)
if __name__ == "__main__":
# Run tests with xmlrunner and output the results as XML
with open('test-reports/results.xml', 'wb') as output:
unittest.main(testRunner=xmlrunner.XMLTestRunner(output=output))
This is the output:
Running tests...
----------------------------------------------------------------------
u
======================================================================
Traceback (most recent call last):
File "simpletest.py", line 13, in <module>
unittest.main(testRunner=xmlrunner.XMLTestRunner(output=output))
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/unittest/main.py", line 102, in __init__
self.runTests()
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/unittest/main.py", line 274, in runTests
self.result = testRunner.run(self.test)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/xmlrunner/runner.py", line 72, in run
result.printErrors()
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/unittest/runner.py", line 149, in printErrors
self.stream.writeln(f"UNEXPECTED SUCCESS: {self.getDescription(test)}")
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/unittest/runner.py", line 47, in getDescription
doc_first_line = test.shortDescription()
^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'tuple' object has no attribute 'shortDescription'
The following script fails:
This is the output:
It seems that
unittest
expects a scalar test, but gets a tuple(test, "unexpected success")
.The text was updated successfully, but these errors were encountered: