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.
| 338 | |
| 339 | |
| 340 | class _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 | |
| 378 | def _isnotsuite(test): |
| 379 | "A crude way to tell apart testcases and suites with duck-typing" |
no outgoing calls
no test coverage detected
searching dependent graphs…