Skip to content

Commit a6d3510

Browse files
elazarggvanrossum
authored andcommitted
Move data driven part of stubgen to pytest (#3880)
1 parent c000062 commit a6d3510

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

mypy/test/teststubgen.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
from mypy.myunit import Suite, AssertionFailure, assert_equal
1515
from mypy.test.helpers import assert_string_arrays_equal
16-
from mypy.test.data import parse_test_cases, DataDrivenTestCase
16+
from mypy.test.data import DataSuite, parse_test_cases, DataDrivenTestCase
1717
from mypy.test import config
1818
from mypy.parse import parse
1919
from mypy.errors import CompileError
@@ -95,15 +95,19 @@ def test_infer_sig_from_docstring(self) -> None:
9595
assert_equal(infer_sig_from_docstring('\nfunc x', 'func'), None)
9696

9797

98-
class StubgenPythonSuite(Suite):
98+
class StubgenPythonSuite(DataSuite):
9999
test_data_files = ['stubgen.test']
100100

101-
def cases(self) -> List[DataDrivenTestCase]:
101+
@classmethod
102+
def cases(cls) -> List[DataDrivenTestCase]:
102103
c = [] # type: List[DataDrivenTestCase]
103-
for path in self.test_data_files:
104+
for path in cls.test_data_files:
104105
c += parse_test_cases(os.path.join(config.test_data_prefix, path), test_stubgen)
105106
return c
106107

108+
def run_case(self, testcase: DataDrivenTestCase) -> None:
109+
test_stubgen(testcase)
110+
107111

108112
def parse_flags(program_text: str) -> Options:
109113
flags = re.search('# flags: (.*)$', program_text, flags=re.MULTILINE)

runtests.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ def test_path(*names: str):
217217

218218
SLOW_FILES = test_path(
219219
'testpythoneval',
220-
'testcmdline'
220+
'testcmdline',
221+
'teststubgen',
221222
)
222223

223224
MYUNIT_FILES = test_path(
@@ -229,7 +230,7 @@ def test_path(*names: str):
229230
'testreports',
230231
'testsolve',
231232
'testsubtypes',
232-
'testtypes'
233+
'testtypes',
233234
)
234235

235236
for f in find_files('mypy', prefix='test', suffix='.py'):

0 commit comments

Comments
 (0)