From 21bbcd0d0cc476f46171424e895c9ce73027132b Mon Sep 17 00:00:00 2001 From: Ivor Wanders Date: Tue, 7 Nov 2023 18:37:53 -0500 Subject: [PATCH] fix(smart_holder): Use regex matching for deleter constructors in unit tests. --- tests/test_class_sh_basic.py | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/tests/test_class_sh_basic.py b/tests/test_class_sh_basic.py index b3e9709dd24..7be0747c2aa 100644 --- a/tests/test_class_sh_basic.py +++ b/tests/test_class_sh_basic.py @@ -66,18 +66,32 @@ def test_load_with_rtrn_f(pass_f, rtrn_f, expected): @pytest.mark.parametrize( - ("pass_f", "rtrn_f", "expected"), + ("pass_f", "rtrn_f", "regex_expected"), [ - (m.pass_udmp_del, m.rtrn_udmp_del, "pass_udmp_del:rtrn_udmp_del,udmp_deleter_" + "_".join(["MvCtorTo"] * 6)), - (m.pass_udcp_del, m.rtrn_udcp_del, "pass_udcp_del:rtrn_udcp_del,udcp_deleter_" + "_".join(["MvCtorTo"] * 8)), - (m.pass_udmp_del_nd, m.rtrn_udmp_del_nd, - "pass_udmp_del_nd:rtrn_udmp_del_nd,udmp_deleter_nd_" + "_".join(["MvCtorTo"] * 6)), - (m.pass_udcp_del_nd, m.rtrn_udcp_del_nd, - "pass_udcp_del_nd:rtrn_udcp_del_nd,udcp_deleter_nd_" + "_".join(["MvCtorTo"] * 8)), + ( + m.pass_udmp_del, + m.rtrn_udmp_del, + "pass_udmp_del:rtrn_udmp_del,udmp_deleter(_MvCtorTo)*_MvCtorTo", + ), + ( + m.pass_udcp_del, + m.rtrn_udcp_del, + "pass_udcp_del:rtrn_udcp_del,udcp_deleter(_MvCtorTo)*_MvCtorTo", + ), + ( + m.pass_udmp_del_nd, + m.rtrn_udmp_del_nd, + "pass_udmp_del_nd:rtrn_udmp_del_nd,udmp_deleter_nd(_MvCtorTo)*_MvCtorTo", + ), + ( + m.pass_udcp_del_nd, + m.rtrn_udcp_del_nd, + "pass_udcp_del_nd:rtrn_udcp_del_nd,udcp_deleter_nd(_MvCtorTo)*_MvCtorTo", + ), ], ) -def test_deleter_roundtrip(pass_f, rtrn_f, expected): - assert pass_f(rtrn_f()) == expected +def test_deleter_roundtrip(pass_f, rtrn_f, regex_expected): + assert re.match(regex_expected, pass_f(rtrn_f())) @pytest.mark.parametrize(