Skip to content

Move testsemanal to pytest #3866

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 24, 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
37 changes: 23 additions & 14 deletions mypy/test/testsemanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@

from mypy import build
from mypy.build import BuildSource
from mypy.myunit import Suite
from mypy.test.helpers import (
assert_string_arrays_equal, normalize_error_messages, testfile_pyversion,
)
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
Expand Down Expand Up @@ -42,8 +41,9 @@ def get_semanal_options() -> Options:
return options


class SemAnalSuite(Suite):
def cases(self) -> List[DataDrivenTestCase]:
class SemAnalSuite(DataSuite):
@classmethod
def cases(cls) -> List[DataDrivenTestCase]:
c = [] # type: List[DataDrivenTestCase]
for f in semanal_files:
c += parse_test_cases(os.path.join(test_data_prefix, f),
Expand All @@ -53,6 +53,9 @@ def cases(self) -> List[DataDrivenTestCase]:
native_sep=True)
return c

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


def test_semanal(testcase: DataDrivenTestCase) -> None:
"""Perform a semantic analysis test case.
Expand Down Expand Up @@ -102,15 +105,19 @@ def test_semanal(testcase: DataDrivenTestCase) -> None:
semanal_error_files = ['semanal-errors.test']


class SemAnalErrorSuite(Suite):
def cases(self) -> List[DataDrivenTestCase]:
class SemAnalErrorSuite(DataSuite):
@classmethod
def cases(cls) -> List[DataDrivenTestCase]:
# Read test cases from test case description files.
c = [] # type: List[DataDrivenTestCase]
for f in semanal_error_files:
c += parse_test_cases(os.path.join(test_data_prefix, f),
test_semanal_error, test_temp_dir, optional_out=True)
return c

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


def test_semanal_error(testcase: DataDrivenTestCase) -> None:
"""Perform a test case."""
Expand All @@ -137,15 +144,16 @@ def test_semanal_error(testcase: DataDrivenTestCase) -> None:
semanal_symtable_files = ['semanal-symtable.test']


class SemAnalSymtableSuite(Suite):
def cases(self) -> List[DataDrivenTestCase]:
class SemAnalSymtableSuite(DataSuite):
@classmethod
def cases(cls) -> List[DataDrivenTestCase]:
c = [] # type: List[DataDrivenTestCase]
for f in semanal_symtable_files:
c += parse_test_cases(os.path.join(test_data_prefix, f),
self.run_test, test_temp_dir)
None, test_temp_dir)
return c

def run_test(self, testcase: DataDrivenTestCase) -> None:
def run_case(self, testcase: DataDrivenTestCase) -> None:
"""Perform a test case."""
try:
# Build test case input.
Expand Down Expand Up @@ -175,16 +183,17 @@ def run_test(self, testcase: DataDrivenTestCase) -> None:
semanal_typeinfo_files = ['semanal-typeinfo.test']


class SemAnalTypeInfoSuite(Suite):
def cases(self) -> List[DataDrivenTestCase]:
class SemAnalTypeInfoSuite(DataSuite):
@classmethod
def cases(cls) -> List[DataDrivenTestCase]:
"""Test case descriptions"""
c = [] # type: List[DataDrivenTestCase]
for f in semanal_typeinfo_files:
c += parse_test_cases(os.path.join(test_data_prefix, f),
self.run_test, test_temp_dir)
None, test_temp_dir)
return c

def run_test(self, testcase: DataDrivenTestCase) -> None:
def run_case(self, testcase: DataDrivenTestCase) -> None:
"""Perform a test case."""
try:
# Build test case input.
Expand Down
1 change: 1 addition & 0 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ def add_imports(driver: Driver) -> None:
'testtransform',
'testtypegen',
'testparse',
'testsemanal',
]]


Expand Down