@@ -32,10 +32,11 @@ class PythonCmdlineSuite(DataSuite):
32
32
native_sep = True
33
33
34
34
def run_case (self , testcase : DataDrivenTestCase ) -> None :
35
- test_python_cmdline (testcase )
35
+ for step in [1 ] + sorted (testcase .output2 ):
36
+ test_python_cmdline (testcase , step )
36
37
37
38
38
- def test_python_cmdline (testcase : DataDrivenTestCase ) -> None :
39
+ def test_python_cmdline (testcase : DataDrivenTestCase , step : int ) -> None :
39
40
assert testcase .old_cwd is not None , "test was not properly set up"
40
41
# Write the program to a file.
41
42
program = '_program.py'
@@ -75,12 +76,14 @@ def test_python_cmdline(testcase: DataDrivenTestCase) -> None:
75
76
# Ignore stdout, but we insist on empty stderr and zero status.
76
77
if err or result :
77
78
raise AssertionError (
78
- 'Expected zero status and empty stderr, got %d and\n %s' %
79
- (result , '\n ' .join (err + out )))
79
+ 'Expected zero status and empty stderr%s, got %d and\n %s' %
80
+ (' on step %d' % step if testcase .output2 else '' ,
81
+ result , '\n ' .join (err + out )))
80
82
for path , expected_content in testcase .output_files :
81
83
if not os .path .exists (path ):
82
84
raise AssertionError (
83
- 'Expected file {} was not produced by test case' .format (path ))
85
+ 'Expected file {} was not produced by test case{}' .format (
86
+ path , ' on step %d' % step if testcase .output2 else '' ))
84
87
with open (path , 'r' , encoding = 'utf8' ) as output_file :
85
88
actual_output_content = output_file .read ().splitlines ()
86
89
normalized_output = normalize_file_output (actual_output_content ,
@@ -93,17 +96,19 @@ def test_python_cmdline(testcase: DataDrivenTestCase) -> None:
93
96
for line in normalized_output ]
94
97
normalized_output = normalize_error_messages (normalized_output )
95
98
assert_string_arrays_equal (expected_content .splitlines (), normalized_output ,
96
- 'Output file {} did not match its expected output' .format (
97
- path ))
99
+ 'Output file {} did not match its expected output{} ' .format (
100
+ path , ' on step %d' % step if testcase . output2 else '' ))
98
101
else :
99
102
if testcase .normalize_output :
100
103
out = normalize_error_messages (err + out )
101
104
obvious_result = 1 if out else 0
102
105
if obvious_result != result :
103
106
out .append ('== Return code: {}' .format (result ))
104
- assert_string_arrays_equal (testcase .output , out ,
105
- 'Invalid output ({}, line {})' .format (
106
- testcase .file , testcase .line ))
107
+ expected_out = testcase .output if step == 1 else testcase .output2 [step ]
108
+ assert_string_arrays_equal (expected_out , out ,
109
+ 'Invalid output ({}, line {}){}' .format (
110
+ testcase .file , testcase .line ,
111
+ ' on step %d' % step if testcase .output2 else '' ))
107
112
108
113
109
114
def parse_args (line : str ) -> List [str ]:
0 commit comments