(self, result=None)
| 637 | function(*args, **kwargs) |
| 638 | |
| 639 | def run(self, result=None): |
| 640 | if result is None: |
| 641 | result = self.defaultTestResult() |
| 642 | startTestRun = getattr(result, 'startTestRun', None) |
| 643 | stopTestRun = getattr(result, 'stopTestRun', None) |
| 644 | if startTestRun is not None: |
| 645 | startTestRun() |
| 646 | else: |
| 647 | stopTestRun = None |
| 648 | |
| 649 | result.startTest(self) |
| 650 | try: |
| 651 | testMethod = getattr(self, self._testMethodName) |
| 652 | if (getattr(self.__class__, "__unittest_skip__", False) or |
| 653 | getattr(testMethod, "__unittest_skip__", False)): |
| 654 | # If the class or method was skipped. |
| 655 | skip_why = (getattr(self.__class__, '__unittest_skip_why__', '') |
| 656 | or getattr(testMethod, '__unittest_skip_why__', '')) |
| 657 | _addSkip(result, self, skip_why) |
| 658 | return result |
| 659 | |
| 660 | expecting_failure = ( |
| 661 | getattr(self, "__unittest_expecting_failure__", False) or |
| 662 | getattr(testMethod, "__unittest_expecting_failure__", False) |
| 663 | ) |
| 664 | outcome = _Outcome(result) |
| 665 | start_time = time.perf_counter() |
| 666 | try: |
| 667 | self._outcome = outcome |
| 668 | |
| 669 | with outcome.testPartExecutor(self): |
| 670 | self._callSetUp() |
| 671 | if outcome.success: |
| 672 | outcome.expecting_failure = expecting_failure |
| 673 | with outcome.testPartExecutor(self): |
| 674 | self._callTestMethod(testMethod) |
| 675 | outcome.expecting_failure = False |
| 676 | with outcome.testPartExecutor(self): |
| 677 | self._callTearDown() |
| 678 | self.doCleanups() |
| 679 | self._addDuration(result, (time.perf_counter() - start_time)) |
| 680 | |
| 681 | if outcome.success: |
| 682 | if expecting_failure: |
| 683 | if outcome.expectedFailure: |
| 684 | self._addExpectedFailure(result, outcome.expectedFailure) |
| 685 | else: |
| 686 | self._addUnexpectedSuccess(result) |
| 687 | else: |
| 688 | result.addSuccess(self) |
| 689 | return result |
| 690 | finally: |
| 691 | # explicitly break reference cycle: |
| 692 | # outcome.expectedFailure -> frame -> outcome -> outcome.expectedFailure |
| 693 | outcome.expectedFailure = None |
| 694 | outcome = None |
| 695 | |
| 696 | # clear the outcome, no more needed |
no test coverage detected