diff --git a/mypy/test/teststubgen.py b/mypy/test/teststubgen.py index 9f7ecfb8527b..539080c387f9 100644 --- a/mypy/test/teststubgen.py +++ b/mypy/test/teststubgen.py @@ -13,7 +13,7 @@ from mypy.myunit import Suite, AssertionFailure, assert_equal from mypy.test.helpers import assert_string_arrays_equal -from mypy.test.data import parse_test_cases, DataDrivenTestCase +from mypy.test.data import DataSuite, parse_test_cases, DataDrivenTestCase from mypy.test import config from mypy.parse import parse from mypy.errors import CompileError @@ -95,15 +95,19 @@ def test_infer_sig_from_docstring(self) -> None: assert_equal(infer_sig_from_docstring('\nfunc x', 'func'), None) -class StubgenPythonSuite(Suite): +class StubgenPythonSuite(DataSuite): test_data_files = ['stubgen.test'] - def cases(self) -> List[DataDrivenTestCase]: + @classmethod + def cases(cls) -> List[DataDrivenTestCase]: c = [] # type: List[DataDrivenTestCase] - for path in self.test_data_files: + for path in cls.test_data_files: c += parse_test_cases(os.path.join(config.test_data_prefix, path), test_stubgen) return c + def run_case(self, testcase: DataDrivenTestCase) -> None: + test_stubgen(testcase) + def parse_flags(program_text: str) -> Options: flags = re.search('# flags: (.*)$', program_text, flags=re.MULTILINE) diff --git a/runtests.py b/runtests.py index 59b991d77075..7810e1155351 100755 --- a/runtests.py +++ b/runtests.py @@ -212,12 +212,12 @@ def test_path(*names: str): 'testparse', 'testsemanal', 'testpythoneval', - 'testcmdline' + 'testcmdline', + 'teststubgen', ) MYUNIT_FILES = test_path( - 'teststubgen', # contains data-driven suite - + 'teststubgen', 'testargs', 'testgraph', 'testinfer', @@ -225,7 +225,7 @@ def test_path(*names: str): 'testreports', 'testsolve', 'testsubtypes', - 'testtypes' + 'testtypes', ) for f in find_files('mypy', prefix='test', suffix='.py'):