aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test/src/lib/tests.py
diff options
context:
space:
mode:
authorEgor Tensin <egor@tensin.name>2023-12-28 01:00:45 +0100
committerEgor Tensin <egor@tensin.name>2023-12-28 01:00:45 +0100
commita9ae33c4b9dbe566d2ada07affb8b5a135f9b6eb (patch)
tree72b47c96da722d5e034af789f4af432e3fdfa051 /test/src/lib/tests.py
parentjson: factor out json_object_put into json_free (diff)
downloadcimple-a9ae33c4b9dbe566d2ada07affb8b5a135f9b6eb.tar.gz
cimple-a9ae33c4b9dbe566d2ada07affb8b5a135f9b6eb.zip
test/py/ -> test/src/
Diffstat (limited to 'test/src/lib/tests.py')
-rw-r--r--test/src/lib/tests.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/src/lib/tests.py b/test/src/lib/tests.py
new file mode 100644
index 0000000..7ccedef
--- /dev/null
+++ b/test/src/lib/tests.py
@@ -0,0 +1,23 @@
+# Copyright (c) 2023 Egor Tensin <egor@tensin.name>
+# 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:
+ _values = [combination.values if hasattr(combination, 'values') else combination
+ for combination in values]
+ 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)