unittest-parametrize 1.4.0__tar.gz → 1.6.0__tar.gz
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-1.6.0/CHANGELOG.rst +65 -0
- {unittest_parametrize-1.4.0/src/unittest_parametrize.egg-info → unittest_parametrize-1.6.0}/PKG-INFO +17 -20
- {unittest_parametrize-1.4.0 → unittest_parametrize-1.6.0}/README.rst +11 -10
- unittest_parametrize-1.6.0/pyproject.toml +89 -0
- unittest_parametrize-1.6.0/setup.cfg +4 -0
- {unittest_parametrize-1.4.0 → unittest_parametrize-1.6.0}/src/unittest_parametrize/__init__.py +45 -11
- {unittest_parametrize-1.4.0 → unittest_parametrize-1.6.0/src/unittest_parametrize.egg-info}/PKG-INFO +18 -21
- {unittest_parametrize-1.4.0 → unittest_parametrize-1.6.0}/src/unittest_parametrize.egg-info/SOURCES.txt +0 -2
- unittest_parametrize-1.4.0/CHANGELOG.rst +0 -32
- unittest_parametrize-1.4.0/pyproject.toml +0 -28
- unittest_parametrize-1.4.0/setup.cfg +0 -66
- unittest_parametrize-1.4.0/src/unittest_parametrize.egg-info/not-zip-safe +0 -1
- {unittest_parametrize-1.4.0 → unittest_parametrize-1.6.0}/LICENSE +0 -0
- {unittest_parametrize-1.4.0 → unittest_parametrize-1.6.0}/MANIFEST.in +0 -0
- {unittest_parametrize-1.4.0 → unittest_parametrize-1.6.0}/src/unittest_parametrize/py.typed +0 -0
- {unittest_parametrize-1.4.0 → unittest_parametrize-1.6.0}/src/unittest_parametrize.egg-info/dependency_links.txt +0 -0
- {unittest_parametrize-1.4.0 → unittest_parametrize-1.6.0}/src/unittest_parametrize.egg-info/requires.txt +0 -0
- {unittest_parametrize-1.4.0 → unittest_parametrize-1.6.0}/src/unittest_parametrize.egg-info/top_level.txt +0 -0
@@ -0,0 +1,65 @@
|
|
1
|
+
=========
|
2
|
+
Changelog
|
3
|
+
=========
|
4
|
+
|
5
|
+
1.6.0 (2025-01-06)
|
6
|
+
------------------
|
7
|
+
|
8
|
+
* Add suport for asynchronous tests.
|
9
|
+
|
10
|
+
Thanks to Adrien Cossa in `PR #121 <https://github.com/adamchainz/unittest-parametrize/pull/121>`__.
|
11
|
+
|
12
|
+
1.5.0 (2024-10-08)
|
13
|
+
------------------
|
14
|
+
|
15
|
+
* On Python 3.11+, add `exception notes <https://docs.python.org/3.11/whatsnew/3.11.html#whatsnew311-pep678>`__ xwith parameter values to failures.
|
16
|
+
For example, the final line here:
|
17
|
+
|
18
|
+
.. code-block:: console
|
19
|
+
|
20
|
+
$ python -m unittest example
|
21
|
+
F
|
22
|
+
======================================================================
|
23
|
+
FAIL: test_square_0 (example.SquareTests.test_square_0)
|
24
|
+
----------------------------------------------------------------------
|
25
|
+
Traceback (most recent call last):
|
26
|
+
File "/.../unittest_parametrize/__init__.py", line 52, in test
|
27
|
+
return _func(self, *args, **_params, **kwargs)
|
28
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
29
|
+
File "/.../example.py", line 11, in test_square
|
30
|
+
self.assertEqual(x**2, expected)
|
31
|
+
AssertionError: 1 != 2
|
32
|
+
Test parameters: x=1, expected=2
|
33
|
+
|
34
|
+
* Drop Python 3.8 support.
|
35
|
+
|
36
|
+
* Support Python 3.13.
|
37
|
+
|
38
|
+
1.4.0 (2023-10-12)
|
39
|
+
------------------
|
40
|
+
|
41
|
+
* Support whitespace in argument name strings.
|
42
|
+
|
43
|
+
Thanks to Arthur Rio in `PR #47 <https://github.com/adamchainz/unittest-parametrize/pull/47>`__.
|
44
|
+
|
45
|
+
1.3.0 (2023-07-10)
|
46
|
+
------------------
|
47
|
+
|
48
|
+
* Drop Python 3.7 support.
|
49
|
+
|
50
|
+
1.2.0 (2023-06-16)
|
51
|
+
------------------
|
52
|
+
|
53
|
+
* Make ``param.id`` optional.
|
54
|
+
|
55
|
+
Thanks to Adrien Cossa in `PR #20 <https://github.com/adamchainz/unittest-parametrize/pull/20>`__.
|
56
|
+
|
57
|
+
1.1.0 (2023-06-13)
|
58
|
+
------------------
|
59
|
+
|
60
|
+
* Support Python 3.12.
|
61
|
+
|
62
|
+
1.0.0 (2023-03-28)
|
63
|
+
------------------
|
64
|
+
|
65
|
+
* First release.
|
{unittest_parametrize-1.4.0/src/unittest_parametrize.egg-info → unittest_parametrize-1.6.0}/PKG-INFO
RENAMED
@@ -1,28 +1,24 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: unittest-parametrize
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.6.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
|
=====
|
@@ -77,7 +73,7 @@ __ https://docs.pytest.org/en/stable/how-to/parametrize.html#parametrize-basics
|
|
77
73
|
There are two steps to parametrize a test case:
|
78
74
|
|
79
75
|
1. Use ``ParametrizedTestCase`` in the base classes for your test case.
|
80
|
-
2. Apply ``@parametrize`` to any
|
76
|
+
2. Apply ``@parametrize`` to any test methods for parametrization.
|
81
77
|
This decorator takes (at least):
|
82
78
|
|
83
79
|
* the argument names to parametrize, as comma-separated string
|
@@ -105,6 +101,7 @@ Here’s a basic example:
|
|
105
101
|
``@parametrize`` modifies the class at definition time with Python’s |__init_subclass__ hook|__.
|
106
102
|
It removes the original test method and creates wrapped copies with individual names.
|
107
103
|
Thus the parametrization should work regardless of the test runner you use (be it unittest, Django’s test runner, pytest, etc.).
|
104
|
+
It supports both synchronous and asynchronous test methods.
|
108
105
|
|
109
106
|
.. |__init_subclass__ hook| replace:: ``__init_subclass__`` hook
|
110
107
|
__ https://docs.python.org/3/reference/datamodel.html#object.__init_subclass__
|
@@ -2,7 +2,7 @@
|
|
2
2
|
unittest-parametrize
|
3
3
|
====================
|
4
4
|
|
5
|
-
.. image:: https://img.shields.io/github/actions/workflow/status/adamchainz/unittest-parametrize/main.yml?branch=main&style=for-the-badge
|
5
|
+
.. image:: https://img.shields.io/github/actions/workflow/status/adamchainz/unittest-parametrize/main.yml.svg?branch=main&style=for-the-badge
|
6
6
|
:target: https://github.com/adamchainz/unittest-parametrize/actions?workflow=CI
|
7
7
|
|
8
8
|
.. image:: https://img.shields.io/pypi/v/unittest-parametrize.svg?style=for-the-badge
|
@@ -17,6 +17,13 @@ unittest-parametrize
|
|
17
17
|
|
18
18
|
Parametrize tests within unittest TestCases.
|
19
19
|
|
20
|
+
----
|
21
|
+
|
22
|
+
**Testing a Django project?**
|
23
|
+
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.
|
24
|
+
|
25
|
+
----
|
26
|
+
|
20
27
|
Installation
|
21
28
|
============
|
22
29
|
|
@@ -26,14 +33,7 @@ Install with:
|
|
26
33
|
|
27
34
|
python -m pip install unittest-parametrize
|
28
35
|
|
29
|
-
Python 3.
|
30
|
-
|
31
|
-
----
|
32
|
-
|
33
|
-
**Testing a Django project?**
|
34
|
-
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.
|
35
|
-
|
36
|
-
----
|
36
|
+
Python 3.9 to 3.13 supported.
|
37
37
|
|
38
38
|
Usage
|
39
39
|
=====
|
@@ -48,7 +48,7 @@ __ https://docs.pytest.org/en/stable/how-to/parametrize.html#parametrize-basics
|
|
48
48
|
There are two steps to parametrize a test case:
|
49
49
|
|
50
50
|
1. Use ``ParametrizedTestCase`` in the base classes for your test case.
|
51
|
-
2. Apply ``@parametrize`` to any
|
51
|
+
2. Apply ``@parametrize`` to any test methods for parametrization.
|
52
52
|
This decorator takes (at least):
|
53
53
|
|
54
54
|
* the argument names to parametrize, as comma-separated string
|
@@ -76,6 +76,7 @@ Here’s a basic example:
|
|
76
76
|
``@parametrize`` modifies the class at definition time with Python’s |__init_subclass__ hook|__.
|
77
77
|
It removes the original test method and creates wrapped copies with individual names.
|
78
78
|
Thus the parametrization should work regardless of the test runner you use (be it unittest, Django’s test runner, pytest, etc.).
|
79
|
+
It supports both synchronous and asynchronous test methods.
|
79
80
|
|
80
81
|
.. |__init_subclass__ hook| replace:: ``__init_subclass__`` hook
|
81
82
|
__ https://docs.python.org/3/reference/datamodel.html#object.__init_subclass__
|
@@ -0,0 +1,89 @@
|
|
1
|
+
[build-system]
|
2
|
+
build-backend = "setuptools.build_meta"
|
3
|
+
requires = [
|
4
|
+
"setuptools",
|
5
|
+
]
|
6
|
+
|
7
|
+
[project]
|
8
|
+
name = "unittest-parametrize"
|
9
|
+
version = "1.6.0"
|
10
|
+
description = "Parametrize tests within unittest TestCases."
|
11
|
+
readme = "README.rst"
|
12
|
+
keywords = [
|
13
|
+
"unittest",
|
14
|
+
]
|
15
|
+
authors = [
|
16
|
+
{ name = "Adam Johnson", email = "me@adamj.eu" },
|
17
|
+
]
|
18
|
+
requires-python = ">=3.9"
|
19
|
+
classifiers = [
|
20
|
+
"Development Status :: 5 - Production/Stable",
|
21
|
+
"Intended Audience :: Developers",
|
22
|
+
"License :: OSI Approved :: MIT License",
|
23
|
+
"Natural Language :: English",
|
24
|
+
"Programming Language :: Python :: 3 :: Only",
|
25
|
+
"Programming Language :: Python :: 3.9",
|
26
|
+
"Programming Language :: Python :: 3.10",
|
27
|
+
"Programming Language :: Python :: 3.11",
|
28
|
+
"Programming Language :: Python :: 3.12",
|
29
|
+
"Programming Language :: Python :: 3.13",
|
30
|
+
"Typing :: Typed",
|
31
|
+
]
|
32
|
+
dependencies = [
|
33
|
+
"typing-extensions; python_version<'3.10'",
|
34
|
+
]
|
35
|
+
urls.Changelog = "https://github.com/adamchainz/unittest-parametrize/blob/main/CHANGELOG.rst"
|
36
|
+
urls.Funding = "https://adamj.eu/books/"
|
37
|
+
urls.Repository = "https://github.com/adamchainz/unittest-parametrize"
|
38
|
+
|
39
|
+
[tool.isort]
|
40
|
+
add_imports = [
|
41
|
+
"from __future__ import annotations",
|
42
|
+
]
|
43
|
+
force_single_line = true
|
44
|
+
profile = "black"
|
45
|
+
|
46
|
+
[tool.pyproject-fmt]
|
47
|
+
max_supported_python = "3.13"
|
48
|
+
|
49
|
+
[tool.pytest.ini_options]
|
50
|
+
addopts = """\
|
51
|
+
--strict-config
|
52
|
+
--strict-markers
|
53
|
+
"""
|
54
|
+
xfail_strict = true
|
55
|
+
|
56
|
+
[tool.coverage.run]
|
57
|
+
branch = true
|
58
|
+
parallel = true
|
59
|
+
source = [
|
60
|
+
"unittest_parametrize",
|
61
|
+
"tests",
|
62
|
+
]
|
63
|
+
|
64
|
+
[tool.coverage.paths]
|
65
|
+
source = [
|
66
|
+
"src",
|
67
|
+
".tox/**/site-packages",
|
68
|
+
]
|
69
|
+
|
70
|
+
[tool.coverage.report]
|
71
|
+
show_missing = true
|
72
|
+
|
73
|
+
[tool.mypy]
|
74
|
+
enable_error_code = [
|
75
|
+
"ignore-without-code",
|
76
|
+
"redundant-expr",
|
77
|
+
"truthy-bool",
|
78
|
+
]
|
79
|
+
mypy_path = "src/"
|
80
|
+
namespace_packages = false
|
81
|
+
strict = true
|
82
|
+
warn_unreachable = true
|
83
|
+
|
84
|
+
[[tool.mypy.overrides]]
|
85
|
+
module = "tests.*"
|
86
|
+
allow_untyped_defs = true
|
87
|
+
|
88
|
+
[tool.rstcheck]
|
89
|
+
report_level = "ERROR"
|
{unittest_parametrize-1.4.0 → unittest_parametrize-1.6.0}/src/unittest_parametrize/__init__.py
RENAMED
@@ -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
|
|
@@ -40,15 +40,49 @@ class ParametrizedTestCase(TestCase):
|
|
40
40
|
for param in _parametrized.params:
|
41
41
|
params = dict(zip(_parametrized.argnames, param.args))
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
43
|
+
if inspect.iscoroutinefunction(func):
|
44
|
+
|
45
|
+
@wraps(func)
|
46
|
+
async def test(
|
47
|
+
self: TestCase,
|
48
|
+
*args: Any,
|
49
|
+
_func: FunctionType = func,
|
50
|
+
_params: dict[str, Any] = params,
|
51
|
+
**kwargs: Any,
|
52
|
+
) -> Any:
|
53
|
+
try:
|
54
|
+
return await _func(self, *args, **_params, **kwargs)
|
55
|
+
except Exception as exc:
|
56
|
+
if sys.version_info >= (3, 11):
|
57
|
+
exc.add_note(
|
58
|
+
"Test parameters: "
|
59
|
+
+ ", ".join(
|
60
|
+
f"{k}={v!r}" for k, v in _params.items()
|
61
|
+
)
|
62
|
+
)
|
63
|
+
raise
|
64
|
+
|
65
|
+
else:
|
66
|
+
|
67
|
+
@wraps(func)
|
68
|
+
def test(
|
69
|
+
self: TestCase,
|
70
|
+
*args: Any,
|
71
|
+
_func: FunctionType = func,
|
72
|
+
_params: dict[str, Any] = params,
|
73
|
+
**kwargs: Any,
|
74
|
+
) -> Any:
|
75
|
+
try:
|
76
|
+
return _func(self, *args, **_params, **kwargs)
|
77
|
+
except Exception as exc:
|
78
|
+
if sys.version_info >= (3, 11):
|
79
|
+
exc.add_note(
|
80
|
+
"Test parameters: "
|
81
|
+
+ ", ".join(
|
82
|
+
f"{k}={v!r}" for k, v in _params.items()
|
83
|
+
)
|
84
|
+
)
|
85
|
+
raise
|
52
86
|
|
53
87
|
test.__name__ = f"{name}_{param.id}"
|
54
88
|
test.__qualname__ = f"{test.__qualname__}_{param.id}"
|
@@ -135,7 +169,7 @@ def parametrize(
|
|
135
169
|
)
|
136
170
|
|
137
171
|
_parametrized = parametrized(argnames, params)
|
138
|
-
bind_kwargs =
|
172
|
+
bind_kwargs = dict.fromkeys(_parametrized.argnames)
|
139
173
|
|
140
174
|
def wrapper(func: Callable[P, T]) -> Callable[P, T]:
|
141
175
|
# Check given argnames will work
|
{unittest_parametrize-1.4.0 → unittest_parametrize-1.6.0/src/unittest_parametrize.egg-info}/PKG-INFO
RENAMED
@@ -1,28 +1,24 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
|
-
Name:
|
3
|
-
Version: 1.
|
2
|
+
Name: unittest-parametrize
|
3
|
+
Version: 1.6.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
|
=====
|
@@ -77,7 +73,7 @@ __ https://docs.pytest.org/en/stable/how-to/parametrize.html#parametrize-basics
|
|
77
73
|
There are two steps to parametrize a test case:
|
78
74
|
|
79
75
|
1. Use ``ParametrizedTestCase`` in the base classes for your test case.
|
80
|
-
2. Apply ``@parametrize`` to any
|
76
|
+
2. Apply ``@parametrize`` to any test methods for parametrization.
|
81
77
|
This decorator takes (at least):
|
82
78
|
|
83
79
|
* the argument names to parametrize, as comma-separated string
|
@@ -105,6 +101,7 @@ Here’s a basic example:
|
|
105
101
|
``@parametrize`` modifies the class at definition time with Python’s |__init_subclass__ hook|__.
|
106
102
|
It removes the original test method and creates wrapped copies with individual names.
|
107
103
|
Thus the parametrization should work regardless of the test runner you use (be it unittest, Django’s test runner, pytest, etc.).
|
104
|
+
It supports both synchronous and asynchronous test methods.
|
108
105
|
|
109
106
|
.. |__init_subclass__ hook| replace:: ``__init_subclass__`` hook
|
110
107
|
__ https://docs.python.org/3/reference/datamodel.html#object.__init_subclass__
|
@@ -3,12 +3,10 @@ LICENSE
|
|
3
3
|
MANIFEST.in
|
4
4
|
README.rst
|
5
5
|
pyproject.toml
|
6
|
-
setup.cfg
|
7
6
|
src/unittest_parametrize/__init__.py
|
8
7
|
src/unittest_parametrize/py.typed
|
9
8
|
src/unittest_parametrize.egg-info/PKG-INFO
|
10
9
|
src/unittest_parametrize.egg-info/SOURCES.txt
|
11
10
|
src/unittest_parametrize.egg-info/dependency_links.txt
|
12
|
-
src/unittest_parametrize.egg-info/not-zip-safe
|
13
11
|
src/unittest_parametrize.egg-info/requires.txt
|
14
12
|
src/unittest_parametrize.egg-info/top_level.txt
|
@@ -1,32 +0,0 @@
|
|
1
|
-
=========
|
2
|
-
Changelog
|
3
|
-
=========
|
4
|
-
|
5
|
-
1.4.0 (2023-10-12)
|
6
|
-
------------------
|
7
|
-
|
8
|
-
* Support whitespace in argument name strings.
|
9
|
-
|
10
|
-
Thanks to Arthur Rio in `PR #47 <https://github.com/adamchainz/unittest-parametrize/pull/47>`__.
|
11
|
-
|
12
|
-
1.3.0 (2023-07-10)
|
13
|
-
------------------
|
14
|
-
|
15
|
-
* Drop Python 3.7 support.
|
16
|
-
|
17
|
-
1.2.0 (2023-06-16)
|
18
|
-
------------------
|
19
|
-
|
20
|
-
* Make ``param.id`` optional.
|
21
|
-
|
22
|
-
Thanks to Adrien Cossa in `PR #20 <https://github.com/adamchainz/unittest-parametrize/pull/20>`__.
|
23
|
-
|
24
|
-
1.1.0 (2023-06-13)
|
25
|
-
------------------
|
26
|
-
|
27
|
-
* Support Python 3.12.
|
28
|
-
|
29
|
-
1.0.0 (2023-03-28)
|
30
|
-
------------------
|
31
|
-
|
32
|
-
* First release.
|
@@ -1,28 +0,0 @@
|
|
1
|
-
[build-system]
|
2
|
-
build-backend = "setuptools.build_meta"
|
3
|
-
requires = [
|
4
|
-
"setuptools",
|
5
|
-
]
|
6
|
-
|
7
|
-
[tool.black]
|
8
|
-
target-version = ['py38']
|
9
|
-
|
10
|
-
[tool.pytest.ini_options]
|
11
|
-
addopts = """\
|
12
|
-
--strict-config
|
13
|
-
--strict-markers
|
14
|
-
"""
|
15
|
-
|
16
|
-
[tool.mypy]
|
17
|
-
mypy_path = "src/"
|
18
|
-
namespace_packages = false
|
19
|
-
show_error_codes = true
|
20
|
-
strict = true
|
21
|
-
warn_unreachable = true
|
22
|
-
|
23
|
-
[[tool.mypy.overrides]]
|
24
|
-
module = "tests.*"
|
25
|
-
allow_untyped_defs = true
|
26
|
-
|
27
|
-
[tool.rstcheck]
|
28
|
-
report_level = "ERROR"
|
@@ -1,66 +0,0 @@
|
|
1
|
-
[metadata]
|
2
|
-
name = unittest_parametrize
|
3
|
-
version = 1.4.0
|
4
|
-
description = Parametrize tests within unittest TestCases.
|
5
|
-
long_description = file: README.rst
|
6
|
-
long_description_content_type = text/x-rst
|
7
|
-
url = https://github.com/adamchainz/unittest-parametrize
|
8
|
-
author = Adam Johnson
|
9
|
-
author_email = me@adamj.eu
|
10
|
-
license = MIT
|
11
|
-
license_files = LICENSE
|
12
|
-
classifiers =
|
13
|
-
Development Status :: 5 - Production/Stable
|
14
|
-
Intended Audience :: Developers
|
15
|
-
License :: OSI Approved :: MIT License
|
16
|
-
Natural Language :: English
|
17
|
-
Programming Language :: Python :: 3
|
18
|
-
Programming Language :: Python :: 3 :: Only
|
19
|
-
Programming Language :: Python :: 3.8
|
20
|
-
Programming Language :: Python :: 3.9
|
21
|
-
Programming Language :: Python :: 3.10
|
22
|
-
Programming Language :: Python :: 3.11
|
23
|
-
Programming Language :: Python :: 3.12
|
24
|
-
Typing :: Typed
|
25
|
-
keywords = unittest
|
26
|
-
project_urls =
|
27
|
-
Changelog = https://github.com/adamchainz/unittest-parametrize/blob/main/CHANGELOG.rst
|
28
|
-
Mastodon = https://fosstodon.org/@adamchainz
|
29
|
-
Twitter = https://twitter.com/adamchainz
|
30
|
-
|
31
|
-
[options]
|
32
|
-
packages = find:
|
33
|
-
install_requires =
|
34
|
-
typing-extensions;python_version < "3.10"
|
35
|
-
python_requires = >=3.8
|
36
|
-
include_package_data = True
|
37
|
-
package_dir =
|
38
|
-
=src
|
39
|
-
zip_safe = False
|
40
|
-
|
41
|
-
[options.packages.find]
|
42
|
-
where = src
|
43
|
-
|
44
|
-
[coverage:run]
|
45
|
-
branch = True
|
46
|
-
parallel = True
|
47
|
-
source =
|
48
|
-
unittest_parametrize
|
49
|
-
tests
|
50
|
-
|
51
|
-
[coverage:paths]
|
52
|
-
source =
|
53
|
-
src
|
54
|
-
.tox/**/site-packages
|
55
|
-
|
56
|
-
[coverage:report]
|
57
|
-
show_missing = True
|
58
|
-
|
59
|
-
[flake8]
|
60
|
-
max-line-length = 88
|
61
|
-
extend-ignore = E203
|
62
|
-
|
63
|
-
[egg_info]
|
64
|
-
tag_build =
|
65
|
-
tag_date = 0
|
66
|
-
|
@@ -1 +0,0 @@
|
|
1
|
-
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|