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.
| 325 | |
| 326 | |
| 327 | class _ErrorHolder(object): |
| 328 | """ |
| 329 | Placeholder for a TestCase inside a result. As far as a TestResult |
| 330 | is concerned, this looks exactly like a unit test. Used to insert |
| 331 | arbitrary errors into a test suite run. |
| 332 | """ |
| 333 | # Inspired by the ErrorHolder from Twisted: |
| 334 | # http://twistedmatrix.com/trac/browser/trunk/twisted/trial/runner.py |
| 335 | |
| 336 | # attribute used by TestResult._exc_info_to_string |
| 337 | failureException = None |
| 338 | |
| 339 | def __init__(self, description): |
| 340 | self.description = description |
| 341 | |
| 342 | def id(self): |
| 343 | return self.description |
| 344 | |
| 345 | def shortDescription(self): |
| 346 | return None |
| 347 | |
| 348 | def __repr__(self): |
| 349 | return "<ErrorHolder description=%r>" % (self.description,) |
| 350 | |
| 351 | def __str__(self): |
| 352 | return self.id() |
| 353 | |
| 354 | def run(self, result): |
| 355 | # could call result.addError(...) - but this test-like object |
| 356 | # shouldn't be run anyway |
| 357 | pass |
| 358 | |
| 359 | def __call__(self, result): |
| 360 | return self.run(result) |
| 361 | |
| 362 | def countTestCases(self): |
| 363 | return 0 |
| 364 | |
| 365 | def _isnotsuite(test): |
| 366 | "A crude way to tell apart testcases and suites with duck-typing" |
no outgoing calls
no test coverage detected