comparison tests/basic_test_result.py @ 38616:c44ae5997869

run-tests: add support for external test result The goal is to begin experiment with custom test result. I'm not sure we should offers any backward-compatibility guarantee on that plugin API as it doesn't change often and shouldn't have too much clients. Differential Revision: https://phab.mercurial-scm.org/D3700
author Boris Feld <boris.feld@octobus.net>
date Sat, 28 Apr 2018 12:51:44 +0200
parents
children f4a214300957
comparison
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)