MCPcopy Index your code
hub / github.com/python/cpython / _ErrorHolder

Class _ErrorHolder

Lib/unittest/suite.py:340–376  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

338
339
340class _ErrorHolder(object):
341 """
342 Placeholder for a TestCase inside a result. As far as a TestResult
343 is concerned, this looks exactly like a unit test. Used to insert
344 arbitrary errors into a test suite run.
345 """
346 # Inspired by the ErrorHolder from Twisted:
347 # http://twistedmatrix.com/trac/browser/trunk/twisted/trial/runner.py
348
349 # attribute used by TestResult._exc_info_to_string
350 failureException = None
351
352 def __init__(self, description):
353 self.description = description
354
355 def id(self):
356 return self.description
357
358 def shortDescription(self):
359 return None
360
361 def __repr__(self):
362 return "<ErrorHolder description=%r>" % (self.description,)
363
364 def __str__(self):
365 return self.id()
366
367 def run(self, result):
368 # could call result.addError(...) - but this test-like object
369 # shouldn't be run anyway
370 pass
371
372 def __call__(self, result):
373 return self.run(result)
374
375 def countTestCases(self):
376 return 0
377
378def _isnotsuite(test):
379 "A crude way to tell apart testcases and suites with duck-typing"

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…