colortest¶
ColourTextTestResult (TestResult)
¶
A test result class that prints colour formatted text results to a stream.
Based on https://github.com/python/cpython/blob/3.3/Lib/unittest/runner.py
addError(self, test, err)
¶
Called when an error has occurred. 'err' is a tuple of values as returned by sys.exc_info().
Source code in ontopy/colortest.py
def addError(self, test, err):
super(ColourTextTestResult, self).addError(test, err)
self.printResult('E', 'ERROR', 'error')
addExpectedFailure(self, test, err)
¶
Called when an expected failure/error occurred.
Source code in ontopy/colortest.py
def addExpectedFailure(self, test, err):
super(ColourTextTestResult, self).addExpectedFailure(test, err)
self.printResult('x', 'expected failure', 'expected')
addFailure(self, test, err)
¶
Called when an error has occurred. 'err' is a tuple of values as returned by sys.exc_info().
Source code in ontopy/colortest.py
def addFailure(self, test, err):
super(ColourTextTestResult, self).addFailure(test, err)
self.printResult('F', 'FAIL', 'fail')
addSkip(self, test, reason)
¶
Called when a test is skipped.
Source code in ontopy/colortest.py
def addSkip(self, test, reason):
super(ColourTextTestResult, self).addSkip(test, reason)
if self.checkmode:
self.printResult('s', 'skipped', 'skip')
else:
self.printResult('s', 'skipped {0!r}'.format(reason), 'skip')
addSuccess(self, test)
¶
Called when a test has completed successfully
Source code in ontopy/colortest.py
def addSuccess(self, test):
super(ColourTextTestResult, self).addSuccess(test)
self.printResult('.', 'ok', 'success')
addUnexpectedSuccess(self, test)
¶
Called when a test was expected to fail, but succeed.
Source code in ontopy/colortest.py
def addUnexpectedSuccess(self, test):
super(ColourTextTestResult, self).addUnexpectedSuccess(test)
self.printResult('u', 'unexpected success', 'unexpected')
printErrors(self)
¶
Called by TestRunner after test run
Source code in ontopy/colortest.py
def printErrors(self):
if self.dots or self.showAll:
self.stream.writeln()
self.printErrorList('ERROR', self.errors)
self.printErrorList('FAIL', self.failures)
startTest(self, test)
¶
Called when the given test is about to be run
Source code in ontopy/colortest.py
def startTest(self, test):
super(ColourTextTestResult, self).startTest(test)
pos = 0
if self.showAll:
if self._test_class != test.__class__:
self._test_class = test.__class__
title = self.getClassDescription(test)
self.stream.writeln(self.colours['title'](title))
descr = self.getShortDescription(test)
self.stream.write(descr)
pos += len(descr)
self.stream.write(' ' * (70 - pos))
# self.stream.write(' ' * (self._terminal.width - 10 - pos))
# self.stream.write(' ... ')
self.stream.flush()
ColourTextTestRunner (TextTestRunner)
¶
A test runner that uses colour in its output
resultclass (TestResult)
¶
A test result class that prints colour formatted text results to a stream.
Based on https://github.com/python/cpython/blob/3.3/Lib/unittest/runner.py
addError(self, test, err)
¶
Called when an error has occurred. 'err' is a tuple of values as returned by sys.exc_info().
Source code in ontopy/colortest.py
def addError(self, test, err):
super(ColourTextTestResult, self).addError(test, err)
self.printResult('E', 'ERROR', 'error')
addExpectedFailure(self, test, err)
¶
Called when an expected failure/error occurred.
Source code in ontopy/colortest.py
def addExpectedFailure(self, test, err):
super(ColourTextTestResult, self).addExpectedFailure(test, err)
self.printResult('x', 'expected failure', 'expected')
addFailure(self, test, err)
¶
Called when an error has occurred. 'err' is a tuple of values as returned by sys.exc_info().
Source code in ontopy/colortest.py
def addFailure(self, test, err):
super(ColourTextTestResult, self).addFailure(test, err)
self.printResult('F', 'FAIL', 'fail')
addSkip(self, test, reason)
¶
Called when a test is skipped.
Source code in ontopy/colortest.py
def addSkip(self, test, reason):
super(ColourTextTestResult, self).addSkip(test, reason)
if self.checkmode:
self.printResult('s', 'skipped', 'skip')
else:
self.printResult('s', 'skipped {0!r}'.format(reason), 'skip')
addSuccess(self, test)
¶
Called when a test has completed successfully
Source code in ontopy/colortest.py
def addSuccess(self, test):
super(ColourTextTestResult, self).addSuccess(test)
self.printResult('.', 'ok', 'success')
addUnexpectedSuccess(self, test)
¶
Called when a test was expected to fail, but succeed.
Source code in ontopy/colortest.py
def addUnexpectedSuccess(self, test):
super(ColourTextTestResult, self).addUnexpectedSuccess(test)
self.printResult('u', 'unexpected success', 'unexpected')
printErrors(self)
¶
Called by TestRunner after test run
Source code in ontopy/colortest.py
def printErrors(self):
if self.dots or self.showAll:
self.stream.writeln()
self.printErrorList('ERROR', self.errors)
self.printErrorList('FAIL', self.failures)
startTest(self, test)
¶
Called when the given test is about to be run
Source code in ontopy/colortest.py
def startTest(self, test):
super(ColourTextTestResult, self).startTest(test)
pos = 0
if self.showAll:
if self._test_class != test.__class__:
self._test_class = test.__class__
title = self.getClassDescription(test)
self.stream.writeln(self.colours['title'](title))
descr = self.getShortDescription(test)
self.stream.write(descr)
pos += len(descr)
self.stream.write(' ' * (70 - pos))
# self.stream.write(' ' * (self._terminal.width - 10 - pos))
# self.stream.write(' ... ')
self.stream.flush()