Skip to content

Commit 1e60b35

Browse files
elazarggvanrossum
authored andcommitted
move testsemanal to pytest (#3866)
1 parent df95527 commit 1e60b35

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

mypy/test/testsemanal.py

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66

77
from mypy import build
88
from mypy.build import BuildSource
9-
from mypy.myunit import Suite
109
from mypy.test.helpers import (
1110
assert_string_arrays_equal, normalize_error_messages, testfile_pyversion,
1211
)
13-
from mypy.test.data import parse_test_cases, DataDrivenTestCase
12+
from mypy.test.data import parse_test_cases, DataDrivenTestCase, DataSuite
1413
from mypy.test.config import test_data_prefix, test_temp_dir
1514
from mypy.errors import CompileError
1615
from mypy.nodes import TypeInfo
@@ -42,8 +41,9 @@ def get_semanal_options() -> Options:
4241
return options
4342

4443

45-
class SemAnalSuite(Suite):
46-
def cases(self) -> List[DataDrivenTestCase]:
44+
class SemAnalSuite(DataSuite):
45+
@classmethod
46+
def cases(cls) -> List[DataDrivenTestCase]:
4747
c = [] # type: List[DataDrivenTestCase]
4848
for f in semanal_files:
4949
c += parse_test_cases(os.path.join(test_data_prefix, f),
@@ -53,6 +53,9 @@ def cases(self) -> List[DataDrivenTestCase]:
5353
native_sep=True)
5454
return c
5555

56+
def run_case(self, testcase: DataDrivenTestCase) -> None:
57+
test_semanal(testcase)
58+
5659

5760
def test_semanal(testcase: DataDrivenTestCase) -> None:
5861
"""Perform a semantic analysis test case.
@@ -102,15 +105,19 @@ def test_semanal(testcase: DataDrivenTestCase) -> None:
102105
semanal_error_files = ['semanal-errors.test']
103106

104107

105-
class SemAnalErrorSuite(Suite):
106-
def cases(self) -> List[DataDrivenTestCase]:
108+
class SemAnalErrorSuite(DataSuite):
109+
@classmethod
110+
def cases(cls) -> List[DataDrivenTestCase]:
107111
# Read test cases from test case description files.
108112
c = [] # type: List[DataDrivenTestCase]
109113
for f in semanal_error_files:
110114
c += parse_test_cases(os.path.join(test_data_prefix, f),
111115
test_semanal_error, test_temp_dir, optional_out=True)
112116
return c
113117

118+
def run_case(self, testcase: DataDrivenTestCase) -> None:
119+
test_semanal_error(testcase)
120+
114121

115122
def test_semanal_error(testcase: DataDrivenTestCase) -> None:
116123
"""Perform a test case."""
@@ -137,15 +144,16 @@ def test_semanal_error(testcase: DataDrivenTestCase) -> None:
137144
semanal_symtable_files = ['semanal-symtable.test']
138145

139146

140-
class SemAnalSymtableSuite(Suite):
141-
def cases(self) -> List[DataDrivenTestCase]:
147+
class SemAnalSymtableSuite(DataSuite):
148+
@classmethod
149+
def cases(cls) -> List[DataDrivenTestCase]:
142150
c = [] # type: List[DataDrivenTestCase]
143151
for f in semanal_symtable_files:
144152
c += parse_test_cases(os.path.join(test_data_prefix, f),
145-
self.run_test, test_temp_dir)
153+
None, test_temp_dir)
146154
return c
147155

148-
def run_test(self, testcase: DataDrivenTestCase) -> None:
156+
def run_case(self, testcase: DataDrivenTestCase) -> None:
149157
"""Perform a test case."""
150158
try:
151159
# Build test case input.
@@ -175,16 +183,17 @@ def run_test(self, testcase: DataDrivenTestCase) -> None:
175183
semanal_typeinfo_files = ['semanal-typeinfo.test']
176184

177185

178-
class SemAnalTypeInfoSuite(Suite):
179-
def cases(self) -> List[DataDrivenTestCase]:
186+
class SemAnalTypeInfoSuite(DataSuite):
187+
@classmethod
188+
def cases(cls) -> List[DataDrivenTestCase]:
180189
"""Test case descriptions"""
181190
c = [] # type: List[DataDrivenTestCase]
182191
for f in semanal_typeinfo_files:
183192
c += parse_test_cases(os.path.join(test_data_prefix, f),
184-
self.run_test, test_temp_dir)
193+
None, test_temp_dir)
185194
return c
186195

187-
def run_test(self, testcase: DataDrivenTestCase) -> None:
196+
def run_case(self, testcase: DataDrivenTestCase) -> None:
188197
"""Perform a test case."""
189198
try:
190199
# Build test case input.

runtests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ def add_imports(driver: Driver) -> None:
207207
'testtransform',
208208
'testtypegen',
209209
'testparse',
210+
'testsemanal',
210211
]]
211212

212213

0 commit comments

Comments
 (0)