Skip to content

Move testtransform to pytest #3788

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 1 commit into from
Aug 22, 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
14 changes: 8 additions & 6 deletions mypy/test/testtransform.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,18 @@

from mypy import build
from mypy.build import BuildSource
from mypy.myunit import Suite
from mypy.test.helpers import (
assert_string_arrays_equal, testfile_pyversion, normalize_error_messages
)
from mypy.test.data import parse_test_cases, DataDrivenTestCase
from mypy.test.data import parse_test_cases, DataDrivenTestCase, DataSuite
from mypy.test.config import test_data_prefix, test_temp_dir
from mypy.errors import CompileError
from mypy.nodes import TypeInfo
from mypy.treetransform import TransformVisitor
from mypy.types import Type
from mypy.options import Options


class TransformSuite(Suite):
class TransformSuite(DataSuite):
# Reuse semantic analysis test cases.
transform_files = ['semanal-basic.test',
'semanal-expressions.test',
Expand All @@ -30,15 +28,19 @@ class TransformSuite(Suite):
'semanal-abstractclasses.test',
'semanal-python2.test']

def cases(self) -> List[DataDrivenTestCase]:
@classmethod
def cases(cls) -> List[DataDrivenTestCase]:
c = [] # type: List[DataDrivenTestCase]
for f in self.transform_files:
for f in cls.transform_files:
c += parse_test_cases(os.path.join(test_data_prefix, f),
test_transform,
Copy link
Contributor Author

@elazarg elazarg Aug 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The argument test_transform, which corresponds to the parameter perform, is not used in pytests. The parameter is propagated to DataDrivenTestCase which uses it in the method run(). This method is not called; maybe we should add assert False there.

base_path=test_temp_dir,
native_sep=True)
return c

def run_case(self, testcase: DataDrivenTestCase) -> None:
test_transform(testcase)


def test_transform(testcase: DataDrivenTestCase) -> None:
"""Perform an identity transform test case."""
Expand Down
1 change: 1 addition & 0 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ def add_imports(driver: Driver) -> None:
'testdiff',
'testfinegrained',
'testmerge',
'testtransform',
'testparse',
]]

Expand Down