unittest-parametrize 1.3.0__py3-none-any.whl → 1.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- unittest_parametrize/__init__.py +12 -4
- {unittest_parametrize-1.3.0.dist-info → unittest_parametrize-1.5.0.dist-info}/METADATA +15 -19
- unittest_parametrize-1.5.0.dist-info/RECORD +7 -0
- {unittest_parametrize-1.3.0.dist-info → unittest_parametrize-1.5.0.dist-info}/WHEEL +1 -1
- unittest_parametrize-1.3.0.dist-info/RECORD +0 -7
- {unittest_parametrize-1.3.0.dist-info → unittest_parametrize-1.5.0.dist-info}/LICENSE +0 -0
- {unittest_parametrize-1.3.0.dist-info → unittest_parametrize-1.5.0.dist-info}/top_level.txt +0 -0
unittest_parametrize/__init__.py
CHANGED
@@ -2,11 +2,11 @@ from __future__ import annotations
|
|
2
2
|
|
3
3
|
import inspect
|
4
4
|
import sys
|
5
|
+
from collections.abc import Sequence
|
5
6
|
from functools import wraps
|
6
7
|
from types import FunctionType
|
7
8
|
from typing import Any
|
8
9
|
from typing import Callable
|
9
|
-
from typing import Sequence
|
10
10
|
from typing import TypeVar
|
11
11
|
from unittest import TestCase
|
12
12
|
|
@@ -48,7 +48,15 @@ class ParametrizedTestCase(TestCase):
|
|
48
48
|
_params: dict[str, Any] = params,
|
49
49
|
**kwargs: Any,
|
50
50
|
) -> Any:
|
51
|
-
|
51
|
+
try:
|
52
|
+
return _func(self, *args, **_params, **kwargs)
|
53
|
+
except Exception as exc:
|
54
|
+
if sys.version_info >= (3, 11):
|
55
|
+
exc.add_note(
|
56
|
+
"Test parameters: "
|
57
|
+
+ ", ".join(f"{k}={v!r}" for k, v in _params.items())
|
58
|
+
)
|
59
|
+
raise
|
52
60
|
|
53
61
|
test.__name__ = f"{name}_{param.id}"
|
54
62
|
test.__qualname__ = f"{test.__qualname__}_{param.id}"
|
@@ -92,7 +100,7 @@ def parametrize(
|
|
92
100
|
ids: Sequence[str | None] | None = None,
|
93
101
|
) -> Callable[[Callable[P, T]], Callable[P, T]]:
|
94
102
|
if isinstance(argnames, str):
|
95
|
-
argnames = argnames.split(",")
|
103
|
+
argnames = [a.strip() for a in argnames.split(",")]
|
96
104
|
|
97
105
|
if len(argnames) == 0:
|
98
106
|
raise ValueError("argnames must contain at least one element")
|
@@ -135,7 +143,7 @@ def parametrize(
|
|
135
143
|
)
|
136
144
|
|
137
145
|
_parametrized = parametrized(argnames, params)
|
138
|
-
bind_kwargs =
|
146
|
+
bind_kwargs = dict.fromkeys(_parametrized.argnames)
|
139
147
|
|
140
148
|
def wrapper(func: Callable[P, T]) -> Callable[P, T]:
|
141
149
|
# Check given argnames will work
|
@@ -1,28 +1,24 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: unittest-parametrize
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.5.0
|
4
4
|
Summary: Parametrize tests within unittest TestCases.
|
5
|
-
|
6
|
-
Author: Adam Johnson
|
7
|
-
Author-email: me@adamj.eu
|
8
|
-
License: MIT
|
5
|
+
Author-email: Adam Johnson <me@adamj.eu>
|
9
6
|
Project-URL: Changelog, https://github.com/adamchainz/unittest-parametrize/blob/main/CHANGELOG.rst
|
10
|
-
Project-URL:
|
11
|
-
Project-URL:
|
7
|
+
Project-URL: Funding, https://adamj.eu/books/
|
8
|
+
Project-URL: Repository, https://github.com/adamchainz/unittest-parametrize
|
12
9
|
Keywords: unittest
|
13
10
|
Classifier: Development Status :: 5 - Production/Stable
|
14
11
|
Classifier: Intended Audience :: Developers
|
15
12
|
Classifier: License :: OSI Approved :: MIT License
|
16
13
|
Classifier: Natural Language :: English
|
17
|
-
Classifier: Programming Language :: Python :: 3
|
18
14
|
Classifier: Programming Language :: Python :: 3 :: Only
|
19
|
-
Classifier: Programming Language :: Python :: 3.8
|
20
15
|
Classifier: Programming Language :: Python :: 3.9
|
21
16
|
Classifier: Programming Language :: Python :: 3.10
|
22
17
|
Classifier: Programming Language :: Python :: 3.11
|
23
18
|
Classifier: Programming Language :: Python :: 3.12
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
24
20
|
Classifier: Typing :: Typed
|
25
|
-
Requires-Python: >=3.
|
21
|
+
Requires-Python: >=3.9
|
26
22
|
Description-Content-Type: text/x-rst
|
27
23
|
License-File: LICENSE
|
28
24
|
Requires-Dist: typing-extensions ; python_version < "3.10"
|
@@ -31,7 +27,7 @@ Requires-Dist: typing-extensions ; python_version < "3.10"
|
|
31
27
|
unittest-parametrize
|
32
28
|
====================
|
33
29
|
|
34
|
-
.. image:: https://img.shields.io/github/actions/workflow/status/adamchainz/unittest-parametrize/main.yml?branch=main&style=for-the-badge
|
30
|
+
.. image:: https://img.shields.io/github/actions/workflow/status/adamchainz/unittest-parametrize/main.yml.svg?branch=main&style=for-the-badge
|
35
31
|
:target: https://github.com/adamchainz/unittest-parametrize/actions?workflow=CI
|
36
32
|
|
37
33
|
.. image:: https://img.shields.io/pypi/v/unittest-parametrize.svg?style=for-the-badge
|
@@ -46,6 +42,13 @@ unittest-parametrize
|
|
46
42
|
|
47
43
|
Parametrize tests within unittest TestCases.
|
48
44
|
|
45
|
+
----
|
46
|
+
|
47
|
+
**Testing a Django project?**
|
48
|
+
Check out my book `Speed Up Your Django Tests <https://adamchainz.gumroad.com/l/suydt>`__ which covers loads of recommendations to write faster, more accurate tests.
|
49
|
+
|
50
|
+
----
|
51
|
+
|
49
52
|
Installation
|
50
53
|
============
|
51
54
|
|
@@ -55,14 +58,7 @@ Install with:
|
|
55
58
|
|
56
59
|
python -m pip install unittest-parametrize
|
57
60
|
|
58
|
-
Python 3.
|
59
|
-
|
60
|
-
----
|
61
|
-
|
62
|
-
**Testing a Django project?**
|
63
|
-
Check out my book `Speed Up Your Django Tests <https://adamchainz.gumroad.com/l/suydt>`__ which covers loads of recommendations to write faster, more accurate tests.
|
64
|
-
|
65
|
-
----
|
61
|
+
Python 3.9 to 3.13 supported.
|
66
62
|
|
67
63
|
Usage
|
68
64
|
=====
|
@@ -0,0 +1,7 @@
|
|
1
|
+
unittest_parametrize/__init__.py,sha256=negShGKvE3FB4lYjDQsFLsvILOFvZwz_t57oHhKiA2Y,5193
|
2
|
+
unittest_parametrize/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
+
unittest_parametrize-1.5.0.dist-info/LICENSE,sha256=Jn179RflkRZXhSCGt_D7asLy2Ex47C0WdBHxe0lBazk,1069
|
4
|
+
unittest_parametrize-1.5.0.dist-info/METADATA,sha256=SBSEGl5D0VJAD8ERaNRzl8s3DjNJAGZwjgHR-uG36MQ,15157
|
5
|
+
unittest_parametrize-1.5.0.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
6
|
+
unittest_parametrize-1.5.0.dist-info/top_level.txt,sha256=4nLqNaGtBX8Ny36ZdFt37Gk-87hPtOvfdfZlTBi3OtU,21
|
7
|
+
unittest_parametrize-1.5.0.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
unittest_parametrize/__init__.py,sha256=K1PKWmyhMfTJjaRqv9e42jsVKIbkY5g5Bj1aygTDAoo,4797
|
2
|
-
unittest_parametrize/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
-
unittest_parametrize-1.3.0.dist-info/LICENSE,sha256=Jn179RflkRZXhSCGt_D7asLy2Ex47C0WdBHxe0lBazk,1069
|
4
|
-
unittest_parametrize-1.3.0.dist-info/METADATA,sha256=tEZ-4r1s7jiRP__YCjVe4rQOFuhvW9GUA8tx9UwAANE,15269
|
5
|
-
unittest_parametrize-1.3.0.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
|
6
|
-
unittest_parametrize-1.3.0.dist-info/top_level.txt,sha256=4nLqNaGtBX8Ny36ZdFt37Gk-87hPtOvfdfZlTBi3OtU,21
|
7
|
-
unittest_parametrize-1.3.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|