tests/basic_test_result.py
changeset 38616 c44ae5997869
child 38621 f4a214300957
equal deleted inserted replaced
38614:4d5fb4062f0b 38616:c44ae5997869
       
     1 from __future__ import print_function
       
     2 
       
     3 import unittest
       
     4 
       
     5 class TestResult(unittest._TextTestResult):
       
     6 
       
     7     def __init__(self, options, *args, **kwargs):
       
     8         super(TestResult, self).__init__(*args, **kwargs)
       
     9         self._options = options
       
    10 
       
    11         # unittest.TestResult didn't have skipped until 2.7. We need to
       
    12         # polyfill it.
       
    13         self.skipped = []
       
    14 
       
    15         # We have a custom "ignored" result that isn't present in any Python
       
    16         # unittest implementation. It is very similar to skipped. It may make
       
    17         # sense to map it into skip some day.
       
    18         self.ignored = []
       
    19 
       
    20         self.times = []
       
    21         self._firststarttime = None
       
    22         # Data stored for the benefit of generating xunit reports.
       
    23         self.successes = []
       
    24         self.faildata = {}
       
    25 
       
    26     def addFailure(self, test, reason):
       
    27         print("FAILURE!", test, reason)
       
    28 
       
    29     def addSuccess(self, test):
       
    30         print("SUCCESS!", test)
       
    31 
       
    32     def addError(self, test, err):
       
    33         print("ERR!", test, err)
       
    34 
       
    35     # Polyfill.
       
    36     def addSkip(self, test, reason):
       
    37         print("SKIP!", test, reason)
       
    38 
       
    39     def addIgnore(self, test, reason):
       
    40         print("IGNORE!", test, reason)
       
    41 
       
    42     def addOutputMismatch(self, test, ret, got, expected):
       
    43         return False
       
    44 
       
    45     def stopTest(self, test, interrupted=False):
       
    46         super(TestResult, self).stopTest(test)