From 43b0f9617560f79d398a2b4aafdd56e6ad6f42ad Mon Sep 17 00:00:00 2001 From: elazar Date: Sun, 27 Aug 2017 00:44:15 +0300 Subject: [PATCH 1/2] move stubgen to pytest --- mypy/test/teststubgen.py | 12 ++++++++---- runtests.py | 6 +++--- 2 files changed, 11 insertions(+), 7 deletions(-) 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..e3bcf432ac5c 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', From 1fc948c49a073297c1fcac8df3a6a0b7e657c8a4 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 19 Sep 2017 14:38:31 -0700 Subject: [PATCH 2/2] Add trailing commas to calls --- runtests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtests.py b/runtests.py index e3bcf432ac5c..7810e1155351 100755 --- a/runtests.py +++ b/runtests.py @@ -213,7 +213,7 @@ def test_path(*names: str): 'testsemanal', 'testpythoneval', 'testcmdline', - 'teststubgen' + 'teststubgen', ) MYUNIT_FILES = test_path( @@ -225,7 +225,7 @@ def test_path(*names: str): 'testreports', 'testsolve', 'testsubtypes', - 'testtypes' + 'testtypes', ) for f in find_files('mypy', prefix='test', suffix='.py'):