Skip to content

Commit

Permalink
test: Shorten test_chart_validation_errors test ids (#3551)
Browse files Browse the repository at this point in the history
  • Loading branch information
dangotbanned authored Aug 21, 2024
1 parent 591bf40 commit 5de5138
Showing 1 changed file with 9 additions and 5 deletions.
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

0 comments on commit 5de5138

Please sign in to comment.