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

test: Shorten test_chart_validation_errors test ids #3551

Merged
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
14 changes: 9 additions & 5 deletions tests/utils/test_schemapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,14 +639,16 @@ def chart_error_example__four_errors_hide_fourth():
)


def id_func(val) -> str:
def id_func_chart_error_example(val) -> str:
"""
Ensures the generated test-id name uses only `chart_func` and not `expected_error_message`.
Ensures the generated test-id name uses only the unique portion of `chart_func`.

Without this, the name is ``test_chart_validation_errors[chart_func-expected_error_message]``
Otherwise the name is like below, but ``...`` represents the full error message::

"test_chart_validation_errors[chart_error_example__two_errors_with_one_in_nested_layered_chart-...]"
"""
if isinstance(val, types.FunctionType):
return val.__name__
return val.__name__.replace("chart_error_example__", "")
else:
return ""

Expand Down Expand Up @@ -856,7 +858,9 @@ def id_func(val) -> str:


@pytest.mark.parametrize(
("chart_func", "expected_error_message"), chart_funcs_error_message, ids=id_func
("chart_func", "expected_error_message"),
chart_funcs_error_message,
ids=id_func_chart_error_example,
)
def test_chart_validation_errors(chart_func, expected_error_message):
# For some wrong chart specifications such as an unknown encoding channel,
Expand Down