Skip to content

Move data driven part of stubgen to pytest #3880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions mypy/test/teststubgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,20 +212,20 @@ def test_path(*names: str):
'testparse',
'testsemanal',
'testpythoneval',
'testcmdline'
'testcmdline',
'teststubgen',
)

MYUNIT_FILES = test_path(
'teststubgen', # contains data-driven suite

'teststubgen',
'testargs',
'testgraph',
'testinfer',
'testmoduleinfo',
'testreports',
'testsolve',
'testsubtypes',
'testtypes'
'testtypes',
)

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