From b0358e6353bcd802f52a536dbcaedcaa397c4377 Mon Sep 17 00:00:00 2001 From: "blank@caltech.edu" <blank@caltech.edu> Date: Fri, 25 Oct 2024 16:44:31 +0000 Subject: [PATCH] gogo --- tests/helpers/naming.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/helpers/naming.py diff --git a/tests/helpers/naming.py b/tests/helpers/naming.py new file mode 100644 index 0000000..3fa5fcf --- /dev/null +++ b/tests/helpers/naming.py @@ -0,0 +1,18 @@ +import pytest +from collections.abc import Iterable + +def trans(x): + return str(x) + +def apply_names(func, args, tests, noparens=False): + cases = [] + for case in tests: + if not isinstance(case, Iterable): + case = [case] + extra = ", ".join(args[i] + trans(x) for i, x in enumerate(case) if (args[i] is not True and args[i] is not False)) + cases.append( + pytest.param( + *case, id=func + ("(" if not noparens else "") + ", ".join(trans(x) for i, x in enumerate(case) if args[i] is True) + (")" if not noparens else "" if noparens is True else noparens) + (((", " if noparens is not True else "") + extra) if extra else "") + ) + ) + return cases -- GitLab