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

[mypyc] Show traceback when emitfunc unit test fails #17262

Merged
merged 2 commits into from
May 18, 2024
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
6 changes: 4 additions & 2 deletions mypy/test/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ def render_diff_range(
output.write("\n")


def assert_string_arrays_equal(expected: list[str], actual: list[str], msg: str) -> None:
def assert_string_arrays_equal(
expected: list[str], actual: list[str], msg: str, *, traceback: bool = False
) -> None:
"""Assert that two string arrays are equal.
Display any differences in a human-readable form.
Expand Down Expand Up @@ -136,7 +138,7 @@ def assert_string_arrays_equal(expected: list[str], actual: list[str], msg: str)
"Update the test output using --update-data -n0 "
"(you can additionally use the -k selector to update only specific tests)\n"
)
pytest.fail(msg, pytrace=False)
pytest.fail(msg, pytrace=traceback)


def assert_module_equivalence(name: str, expected: Iterable[str], actual: Iterable[str]) -> None:
Expand Down
4 changes: 3 additions & 1 deletion mypyc/test/test_emitfunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,9 @@ def assert_emit(
else:
expected_lines = expected.rstrip().split("\n")
expected_lines = [line.strip(" ") for line in expected_lines]
assert_string_arrays_equal(expected_lines, actual_lines, msg="Generated code unexpected")
assert_string_arrays_equal(
expected_lines, actual_lines, msg="Generated code unexpected", traceback=True
)
if skip_next:
assert visitor.op_index == 1
else:
Expand Down
Loading