aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test/py/lib
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2023-07-12 05:48:42 +0200
committerEgor Tensin <Egor.Tensin@gmail.com>2023-07-12 05:48:42 +0200
commit8d83b67c2feb539af7566d05e84b1cc154732996 (patch)
tree544dcc73821ee5dafd36cfc161ede74fcc17a291 /test/py/lib
parenttest: use namedtuple where appropriate (diff)
downloadcimple-8d83b67c2feb539af7566d05e84b1cc154732996.tar.gz
cimple-8d83b67c2feb539af7566d05e84b1cc154732996.zip
test: move some code to lib/
Diffstat (limited to '')
-rw-r--r--test/py/lib/tests.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/py/lib/tests.py b/test/py/lib/tests.py
new file mode 100644
index 0000000..a676021
--- /dev/null
+++ b/test/py/lib/tests.py
@@ -0,0 +1,21 @@
+# Copyright (c) 2023 Egor Tensin <Egor.Tensin@gmail.com>
+# This file is part of the "cimple" project.
+# For details, see https://github.com/egor-tensin/cimple.
+# Distributed under the MIT License.
+
+import pytest
+
+
+# Reference: https://github.com/pytest-dev/pytest/issues/3628
+# Automatic generation of readable test IDs.
+def my_parametrize(names, values, ids=None, **kwargs):
+ _names = names.split(',') if isinstance(names, str) else names
+ if not ids:
+ if len(_names) == 1:
+ ids = [f'{names}={v}' for v in values]
+ else:
+ ids = [
+ '-'.join(f'{k}={v}' for k, v in zip(_names, combination))
+ for combination in values
+ ]
+ return pytest.mark.parametrize(names, values, ids=ids, **kwargs)