Skip to content

Commit c21ede7

Browse files
alexandrulgvanrossum
authored andcommitted
Run cmdline tests on AppVeyor (#2815)
Fixes #2663.
1 parent 7000085 commit c21ede7

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

appveyor.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,5 @@ build: off
2727

2828
test_script:
2929
# Ignore lint (it's run separately below)
30-
# and cmdline (since one of its tests depend on lxml)
31-
- "%PYTHON%\\python.exe runtests.py -x lint -x cmdline"
30+
- "%PYTHON%\\python.exe runtests.py -x lint"
3231
- ps: if ($env:PYTHON_VERSION -Match "3.6.x" -And $env:PYTHON_ARCH -Match "64") { iex "$env:PYTHON\\python.exe -m flake8" }

mypy/test/data.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def parse_test_cases(
122122
tc = DataDrivenTestCase(p[i0].arg, input, tcout, tcout2, path,
123123
p[i0].line, lastline, perform,
124124
files, output_files, stale_modules,
125-
rechecked_modules)
125+
rechecked_modules, native_sep)
126126
out.append(tc)
127127
if not ok:
128128
raise ValueError(
@@ -158,6 +158,7 @@ def __init__(self,
158158
output_files: List[Tuple[str, str]],
159159
expected_stale_modules: Optional[Set[str]],
160160
expected_rechecked_modules: Optional[Set[str]],
161+
native_sep: bool = False,
161162
) -> None:
162163
super().__init__(name)
163164
self.input = input
@@ -171,6 +172,7 @@ def __init__(self,
171172
self.output_files = output_files
172173
self.expected_stale_modules = expected_stale_modules
173174
self.expected_rechecked_modules = expected_rechecked_modules
175+
self.native_sep = native_sep
174176

175177
def set_up(self) -> None:
176178
super().set_up()
@@ -409,6 +411,19 @@ def fix_win_path(line: str) -> str:
409411
lineno or '', message)
410412

411413

414+
def fix_cobertura_filename(line: str) -> str:
415+
r"""Changes filename paths to Linux paths in Cobertura output files.
416+
417+
E.g. filename="pkg\subpkg\a.py" -> filename="pkg/subpkg/a.py".
418+
"""
419+
m = re.search(r'<class .* filename="(?P<filename>.*?)"', line)
420+
if not m:
421+
return line
422+
return '{}{}{}'.format(line[:m.start(1)],
423+
m.group('filename').replace('\\', '/'),
424+
line[m.end(1):])
425+
426+
412427
##
413428
#
414429
# pytest setup

mypy/test/testcmdline.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
from mypy.myunit import Suite, SkipTestCaseException, AssertionFailure
1515
from mypy.test.config import test_data_prefix, test_temp_dir
16+
from mypy.test.data import fix_cobertura_filename
1617
from mypy.test.data import parse_test_cases, DataDrivenTestCase
1718
from mypy.test.helpers import assert_string_arrays_equal
1819
from mypy.version import __version__, base_version
@@ -66,9 +67,11 @@ def test_python_evaluation(testcase: DataDrivenTestCase) -> None:
6667
'Expected file {} was not produced by test case'.format(path))
6768
with open(path, 'r') as output_file:
6869
actual_output_content = output_file.read().splitlines()
69-
noramlized_output = normalize_file_output(actual_output_content,
70+
normalized_output = normalize_file_output(actual_output_content,
7071
os.path.abspath(test_temp_dir))
71-
assert_string_arrays_equal(expected_content.splitlines(), noramlized_output,
72+
if testcase.native_sep and os.path.sep == '\\':
73+
normalized_output = [fix_cobertura_filename(line) for line in normalized_output]
74+
assert_string_arrays_equal(expected_content.splitlines(), normalized_output,
7275
'Output file {} did not match its expected output'.format(
7376
path))
7477
else:

0 commit comments

Comments
 (0)