From df619eb1f0e0a765713b37f610c8e244d1311a70 Mon Sep 17 00:00:00 2001 From: dangotbanned <125183946+dangotbanned@users.noreply.github.com> Date: Wed, 21 Aug 2024 13:01:00 +0100 Subject: [PATCH] test: Shorten `test_chart_validation_errors` test ids Follows https://github.com/vega/altair/pull/3501#discussion_r1711277924 --- tests/utils/test_schemapi.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/utils/test_schemapi.py b/tests/utils/test_schemapi.py index 7ae96a864..2f0b9faab 100644 --- a/tests/utils/test_schemapi.py +++ b/tests/utils/test_schemapi.py @@ -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 "" @@ -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,