Skip to content

Commit a590e68

Browse files
[testutil] More information in output for functional test fail (#7948)
In order to help when the target interpreter is not installed locally and you can't update automatically yourself (pypy/old interpreters like python 3.7). Done for: Refs #7945
1 parent b1d3f5a commit a590e68

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

pylint/testutils/lint_module_test.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,12 +287,7 @@ def error_msg_for_unequal_output(
287287
) -> str:
288288
missing = set(expected_lines) - set(received_lines)
289289
unexpected = set(received_lines) - set(expected_lines)
290-
error_msg = (
291-
f"Wrong output for '{self._test_file.base}.txt':\n"
292-
"You can update the expected output automatically with: '"
293-
f"python tests/test_functional.py {UPDATE_OPTION} -k "
294-
f'"test_functional[{self._test_file.base}]"\'\n\n'
295-
)
290+
error_msg = f"Wrong output for '{self._test_file.base}.txt':"
296291
sort_by_line_number = operator.attrgetter("lineno")
297292
if missing:
298293
error_msg += "\n- Missing lines:\n"
@@ -302,6 +297,17 @@ def error_msg_for_unequal_output(
302297
error_msg += "\n- Unexpected lines:\n"
303298
for line in sorted(unexpected, key=sort_by_line_number):
304299
error_msg += f"{line}\n"
300+
error_msg += (
301+
"\nYou can update the expected output automatically with:\n'"
302+
f"python tests/test_functional.py {UPDATE_OPTION} -k "
303+
f'"test_functional[{self._test_file.base}]"\'\n\n'
304+
"Here's the update text in case you can't:\n"
305+
)
306+
expected_csv = StringIO()
307+
writer = csv.writer(expected_csv, dialect="test")
308+
for line in sorted(received_lines, key=sort_by_line_number):
309+
writer.writerow(line.to_csv())
310+
error_msg += expected_csv.getvalue()
305311
return error_msg
306312

307313
def _check_output_text(

0 commit comments

Comments
 (0)