|
7 | 7 | from mypy import defaults |
8 | 8 | from mypy.myunit import Suite, AssertionFailure |
9 | 9 | from mypy.test.helpers import assert_string_arrays_equal |
10 | | -from mypy.test.data import parse_test_cases, DataDrivenTestCase |
| 10 | +from mypy.test.data import parse_test_cases, DataDrivenTestCase, DataSuite |
11 | 11 | from mypy.test import config |
12 | 12 | from mypy.parse import parse |
13 | 13 | from mypy.errors import CompileError |
14 | 14 | from mypy.options import Options |
15 | 15 |
|
16 | 16 |
|
17 | | -class ParserSuite(Suite): |
| 17 | +class ParserSuite(DataSuite): |
18 | 18 | parse_files = ['parse.test', |
19 | 19 | 'parse-python2.test'] |
20 | 20 |
|
21 | | - def cases(self) -> List[DataDrivenTestCase]: |
| 21 | + @classmethod |
| 22 | + def cases(cls) -> List[DataDrivenTestCase]: |
22 | 23 | # The test case descriptions are stored in data files. |
23 | 24 | c = [] # type: List[DataDrivenTestCase] |
24 | | - for f in self.parse_files: |
| 25 | + for f in cls.parse_files: |
25 | 26 | c += parse_test_cases( |
26 | 27 | os.path.join(config.test_data_prefix, f), test_parser) |
27 | 28 | return c |
28 | 29 |
|
| 30 | + def run_case(self, testcase: DataDrivenTestCase) -> None: |
| 31 | + test_parser(testcase) |
| 32 | + |
29 | 33 |
|
30 | 34 | def test_parser(testcase: DataDrivenTestCase) -> None: |
31 | 35 | """Perform a single parser test case. |
@@ -57,13 +61,17 @@ def test_parser(testcase: DataDrivenTestCase) -> None: |
57 | 61 | INPUT_FILE_NAME = 'file' |
58 | 62 |
|
59 | 63 |
|
60 | | -class ParseErrorSuite(Suite): |
61 | | - def cases(self) -> List[DataDrivenTestCase]: |
| 64 | +class ParseErrorSuite(DataSuite): |
| 65 | + @classmethod |
| 66 | + def cases(cls) -> List[DataDrivenTestCase]: |
62 | 67 | # Test case descriptions are in an external file. |
63 | 68 | return parse_test_cases(os.path.join(config.test_data_prefix, |
64 | 69 | 'parse-errors.test'), |
65 | 70 | test_parse_error) |
66 | 71 |
|
| 72 | + def run_case(self, testcase: DataDrivenTestCase) -> None: |
| 73 | + test_parse_error(testcase) |
| 74 | + |
67 | 75 |
|
68 | 76 | def test_parse_error(testcase: DataDrivenTestCase) -> None: |
69 | 77 | try: |
|
0 commit comments