def run_test(test_name): """Actually run the test.""" testsuite = unittest.TestSuite() # Import the specific test module_name, testcase_name, method_name = test_name.rsplit('.', 2) module = import_module(module_name) testcase = getattr(module, testcase_name) # Run the specific test testsuite.addTest(testcase(method_name)) # Report the results, if it is a if os.environ.get('TEAMCITY_VERSION') is not None: result = unittest.TestResult() testsuite.run(result) for failure in result.failures: teamcity_message("##teamcity[testFailed name='%s' message='%s' details='%s']" % (test_name, 'Error', escape_for_tc_message_value(failure[1]))) for error in result.errors: teamcity_message("##teamcity[testFailed name='%s' message='%s' details='%s']" % (test_name, 'Error', escape_for_tc_message_value(error[1]))) else: unittest.TextTestRunner(verbosity=2).run(testsuite)
def run_remaining_tests(): """Run the remaining tests""" testsuite = unittest.TestLoader().loadTestsFromTestCase(MessagesTest) # Report the results, if it is a if os.environ.get('TEAMCITY_VERSION') is not None: result = unittest.TestResult() teamcity_message("##teamcity[testStarted name='remaining']") testsuite.run(result) for failure in result.failures: teamcity_message("##teamcity[testFailed name='%s' message='%s' details='%s']" % ("remaining", 'Error', escape_for_tc_message_value(failure[1]))) for error in result.errors: teamcity_message("##teamcity[testFailed name='%s' message='%s' details='%s']" % ("remaining", 'Error', escape_for_tc_message_value(error[1]))) teamcity_message("##teamcity[testFinished name='remaining']") else: unittest.TextTestRunner(verbosity=2).run(testsuite)