# This code us copied unchanged from the unittest package that shipped
# with Python 2.7.4 and is distributed under the PSF License, version 2.
# Copyright the CPython developers and contributors.
[docs]class ErrorHolder(object):
"""
Placeholder for a TestCase inside a result. As far as a TestResult
is concerned, this looks exactly like a unit test. Used to insert
arbitrary errors into a test suite run.
"""
# Inspired by the ErrorHolder from Twisted:
# http://twistedmatrix.com/trac/browser/trunk/twisted/trial/runner.py
# attribute used by TestResult._exc_info_to_string
failureException = None
def __init__(self, description):
self.description = description
[docs] def id(self):
return self.description
@property
def _testMethodName(self):
return self.description
[docs] def shortDescription(self):
return None
def __repr__(self):
return "<ErrorHolder description=%r>" % (self.description,)
def __str__(self):
return self.id()
[docs] def run(self, result):
# could call result.addError(...) - but this test-like object
# shouldn't be run anyway
pass
def __call__(self, result):
return self.run(result)
[docs] def countTestCases(self):
return 0