]>
Commit | Line | Data |
---|---|---|
1a4d82fc | 1 | from __future__ import absolute_import |
223e47cc | 2 | import unittest |
1a4d82fc JJ |
3 | |
4 | import lit.Test | |
223e47cc LB |
5 | |
6 | """ | |
7 | TestCase adaptor for providing a 'unittest' compatible interface to 'lit' tests. | |
8 | """ | |
9 | ||
10 | class UnresolvedError(RuntimeError): | |
11 | pass | |
12 | ||
13 | class LitTestCase(unittest.TestCase): | |
1a4d82fc | 14 | def __init__(self, test, run): |
223e47cc LB |
15 | unittest.TestCase.__init__(self) |
16 | self._test = test | |
1a4d82fc | 17 | self._run = run |
223e47cc LB |
18 | |
19 | def id(self): | |
20 | return self._test.getFullName() | |
21 | ||
22 | def shortDescription(self): | |
23 | return self._test.getFullName() | |
24 | ||
25 | def runTest(self): | |
1a4d82fc JJ |
26 | # Run the test. |
27 | self._run.execute_test(self._test) | |
223e47cc | 28 | |
1a4d82fc JJ |
29 | # Adapt the result to unittest. |
30 | result = self._test.result | |
31 | if result.code is lit.Test.UNRESOLVED: | |
32 | raise UnresolvedError(result.output) | |
33 | elif result.code.isFailure: | |
34 | self.fail(result.output) |