unittest-xml-reporting
                                
                                 unittest-xml-reporting copied to clipboard
                                
                                    unittest-xml-reporting copied to clipboard
                            
                            
                            
                        Return result that supports wasSuccessful()
When running xmlrunner through unittest.main() and passing exit=False, unittest will not set a result code, but sets self.result to the xmrunner result. Because xmlrunner does not return a result compatible with unittest.TestResult there is no good way to check if the run was ok. When checking unittest.result.wasSuccessful() you get "AttributeError: module 'unittest.result' has no attribute 'wasSuccessful'".
Example:
import io
import sys
import unittest
import xmlrunner
def unittestProxy():
        # run the tests storing results in memory
        xmlBytes = io.StringIO()
        xmlRunner=xmlrunner.XMLTestRunner(output=xmlBytes, outsuffix='')
        unittest.main(testRunner=xmlRunner, failfast=False, buffer=False, catchbreak=False, exit=False)
        #...processing xmlBytes here.....
        # store result in XML file
        with open(resultFileName, 'w') as resultFile:
            resultFile.write(xmlBytes)
        # get exit code from unittest run (broken atm)
        sys.exit(not unittest.result.wasSuccessful())
if __name__ == '__main__':
    unittestProxy()
If there's a good workaround please let me know.