def addSuccess(self, test): """ Add success to the result """ TestResult.addSuccess(self, test) self.tests[self.getDescription(test)] = {"status": "SUCCESS"} Printer.success("OK")
def __init__(self, stream=sys.stdout): TestResult.__init__(self) self.output = stream self.test_started_datetime = None self.test_name = None self.createMessages()
def addSkip(self, test, reason): """Called when a test is skipped.""" TestResult.addSkip(self, test, reason) if self.verbose: self.stream.write("skipped (%s)\n" % reason) else: self.stream.write("s") self.stream.flush()
def addSuccess(self, test): "Called when a test has completed successfully" TestResult.addSuccess(self, test) if self.verbose: self.stream.write("ok\n") else: self.stream.write(".") self.stream.flush()
def addError(self, test, err): """Called when an error has occurred.""" TestResult.addError(self, test, err) if self.verbose: self.stream.write("ERROR\n") else: self.stream.write("E") self.stream.flush()
def addError(self, test, err, connection=None): """ Add error to the result """ TestResult.addError(self, test, err) self.tests[self.getDescription(test)] = {"status": "ERROR", "stacktrace": err, "connection": connection} Printer.warn("ERROR") Printer.warn(err[1]) TestHelper.trace(connection)
def addFailure(self, test, err, connection): """ Add failure to the result """ TestResult.addFailure(self, test, err) self.tests[self.getDescription(test)] = {"status": "FAILURE", "stacktrace": err, "connection": connection} Printer.warn("Failure") Printer.warn(err[1]) TestHelper.trace(connection)
def addError(self, test, err, *k): TestResult.addError(self, test, err) err = self.formatErr(err) if self.getTestName(test) != self.test_name: sys.stderr.write("INTERNAL ERROR: addError(%s) outside of test\n" % self.getTestName(test)) sys.stderr.write("Error: %s\n" % err) return self.messages.testFailed(self.getTestName(test), message='Error', details=err)
def addFailure(self, test, err, *k): # workaround nose bug on python 3 if _is_string(err[1]): err = (err[0], Exception(err[1]), err[2]) TestResult.addFailure(self, test, err) err = self.formatErr(err) if self.getTestName(test) != self.test_name: sys.stderr.write("INTERNAL ERROR: addFailure(%s) outside of test\n" % self.getTestName(test)) sys.stderr.write("Error: %s\n" % err) return self.messages.testFailed(self.getTestName(test), message='Failure', details=err)
def test_mock_interface_raises_when_function_not_known(self): class Test(MockTestCase): def runTest(self): mock = self.mock_interface(ILocking) self.expect(mock.crack()).result(True) self.replay() mock.crack() result = TestResult() Test().run(result=result) self.assertFalse(result.wasSuccessful()) self.assertEqual(result.testsRun, 1) self.assertEqual(len(result.failures), 1) self.assertIn('mock.crack()\n - Method not ' + \ 'found in real specification', result.failures[0][1])
def test_mock_interface_raises_on_wrong_arguments(self): class Test(MockTestCase): def runTest(self): mock = self.mock_interface(ILocking) self.expect(mock.unlock(force=True)).result(True) self.replay() mock.unlock(force=True) result = TestResult() Test().run(result=result) self.assertFalse(result.wasSuccessful()) self.assertEqual(result.testsRun, 1) self.assertEqual(len(result.failures), 1) self.assertIn('mock.unlock(force=True)\n - ' + \ 'Specification is unlock(all=False): unknown kwargs: force', result.failures[0][1])
def startTest(self, test): "Called when the given test is about to be run" TestResult.startTest(self, test) if self.verbose: self.stream.write(get_description(test)) self.stream.write(" ... ")
def __init__(self, stream, verbose, stop_on_error): """"Constructor.""" TestResult.__init__(self) self.stream = stream self.verbose = verbose self.failfast = stop_on_error
def __init__(self): """ Initialized a new result """ TestResult.__init__(self) self.tests = OrderedDict()
def addSuccess(self, test): self.success.append((test,u'Success')) TestResult.addSuccess(self, test)
def addSkip(self, test, reason): TestResult.addSkip(self, test, reason) self.output.write("skipped %s - %s\n" % (self.getTestName(test), reason)) #TODO: "testIgnored" should be replaced by "testSkipped" when implemented self.messages.testIgnored(self.getTestName(test), reason)
def addSuccess(self, test, *k): TestResult.addSuccess(self, test) self.output.write("ok\n")