Skip to content
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

Refactoring: Remove handling of @include in test suites #5076

Merged
merged 1 commit into from May 18, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 1 addition & 20 deletions mypy/test/data.py
Expand Up @@ -41,7 +41,6 @@ def parse_test_cases(parent: 'DataSuiteCollector', suite: 'DataSuite',
join = os.path.join
else:
join = posixpath.join # type: ignore
include_path = os.path.dirname(path)
with open(path, encoding='utf-8') as f:
lst = f.readlines()
for i in range(len(lst)):
Expand Down Expand Up @@ -166,7 +165,7 @@ def parse_test_cases(parent: 'DataSuiteCollector', suite: 'DataSuite',
ok = True

if ok:
input = expand_includes(p[i0].data, include_path)
input = p[i0].data
expand_errors(input, tcout, 'main')
for file_path, contents in files:
expand_errors(contents.split('\n'), tcout, file_path)
Expand Down Expand Up @@ -505,24 +504,6 @@ def collapse_line_continuation(l: List[str]) -> List[str]:
return r


def expand_includes(a: List[str], base_path: str) -> List[str]:
"""Expand @includes within a list of lines.

Replace all lies starting with @include with the contents of the
Copy link
Member

Choose a reason for hiding this comment

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

lies indeed.

file name following the prefix. Look for the files in base_path.
"""

res = [] # type: List[str]
for s in a:
if s.startswith('@include '):
fn = s.split(' ', 1)[1].strip()
with open(os.path.join(base_path, fn)) as f:
res.extend(f.readlines())
else:
res.append(s)
return res


def expand_variables(s: str) -> str:
return s.replace('<ROOT>', root_dir)

Expand Down