unittest-parametrize 1.7.0__py3-none-any.whl → 1.8.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.
@@ -120,7 +120,7 @@ TestFunc = Callable[P, T]
120
120
 
121
121
  def parametrize(
122
122
  argnames: str | Sequence[str],
123
- argvalues: Sequence[tuple[Any, ...] | param],
123
+ argvalues: Sequence[tuple[Any, ...] | param | Any],
124
124
  ids: Sequence[str | None] | Callable[[Any], str | None] | None = None,
125
125
  ) -> Callable[[Callable[P, T]], Callable[P, T]]:
126
126
  if isinstance(argnames, str):
@@ -158,10 +158,13 @@ def parametrize(
158
158
  raise ValueError(f"Duplicate param id {argvalue.id!r}")
159
159
  seen_ids.add(argvalue.id)
160
160
  params.append(argvalue)
161
-
161
+ elif len(argnames) == 1:
162
+ argvalue = param(argvalue, id=make_id(i, (argvalue,), ids))
163
+ seen_ids.add(argvalue.id)
164
+ params.append(argvalue)
162
165
  else:
163
166
  raise TypeError(
164
- f"argvalue at index {i} is not a tuple or param instance: {argvalue!r}"
167
+ f"argvalue at index {i} is not a tuple, param instance, or single value: {argvalue!r}"
165
168
  )
166
169
 
167
170
  _parametrized = parametrized(argnames, params)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: unittest-parametrize
3
- Version: 1.7.0
3
+ Version: 1.8.0
4
4
  Summary: Parametrize tests within unittest TestCases.
5
5
  Author-email: Adam Johnson <me@adamj.eu>
6
6
  License-Expression: MIT
@@ -17,6 +17,7 @@ Classifier: Programming Language :: Python :: 3.10
17
17
  Classifier: Programming Language :: Python :: 3.11
18
18
  Classifier: Programming Language :: Python :: 3.12
19
19
  Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
20
21
  Classifier: Typing :: Typed
21
22
  Requires-Python: >=3.9
22
23
  Description-Content-Type: text/x-rst
@@ -59,7 +60,7 @@ Install with:
59
60
 
60
61
  python -m pip install unittest-parametrize
61
62
 
62
- Python 3.9 to 3.13 supported.
63
+ Python 3.9 to 3.14 supported.
63
64
 
64
65
  Usage
65
66
  =====
@@ -77,8 +78,8 @@ There are two steps to parametrize a test case:
77
78
  2. Apply ``@parametrize`` to any test methods for parametrization.
78
79
  This decorator takes (at least):
79
80
 
80
- * the argument names to parametrize, as comma-separated string
81
- * a list of parameter tuples to create individual tests for
81
+ * the argument names to parametrize, as comma-separated string or sequence of strings.
82
+ * a list of parameters to create individual tests for, which may be tuples, ``param`` objects, or single values (for one argument).
82
83
 
83
84
  Here’s a basic example:
84
85
 
@@ -106,6 +107,25 @@ It supports both synchronous and asynchronous test methods.
106
107
  .. |__init_subclass__ hook| replace:: ``__init_subclass__`` hook
107
108
  __ https://docs.python.org/3/reference/datamodel.html#object.__init_subclass__
108
109
 
110
+ Provide a single parameter without a wrapping tuple
111
+ ---------------------------------------------------
112
+
113
+ If you only need a single parameter, you can provide values without wrapping them in tuples:
114
+
115
+ .. code-block:: python
116
+
117
+ from unittest_parametrize import ParametrizedTestCase, parametrize
118
+
119
+
120
+ class EqualTests(ParametrizedTestCase):
121
+ @parametrize(
122
+ "x",
123
+ [1, 2, 3],
124
+ )
125
+ def test_equal(self, x: int) -> None:
126
+ self.assertEqual(x, x)
127
+
128
+
109
129
  Provide argument names as separate strings
110
130
  ------------------------------------------
111
131
 
@@ -0,0 +1,7 @@
1
+ unittest_parametrize/__init__.py,sha256=FP9gc8jyJOHJVe9s52mbMEEsZpyw5vuD3tZxEuLclhg,7433
2
+ unittest_parametrize/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ unittest_parametrize-1.8.0.dist-info/licenses/LICENSE,sha256=Jn179RflkRZXhSCGt_D7asLy2Ex47C0WdBHxe0lBazk,1069
4
+ unittest_parametrize-1.8.0.dist-info/METADATA,sha256=6I1nJVKypKpSdAlx9npkXSVIVN2Y1CM8j4rjey5r_So,18449
5
+ unittest_parametrize-1.8.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
+ unittest_parametrize-1.8.0.dist-info/top_level.txt,sha256=4nLqNaGtBX8Ny36ZdFt37Gk-87hPtOvfdfZlTBi3OtU,21
7
+ unittest_parametrize-1.8.0.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- unittest_parametrize/__init__.py,sha256=32m2wHL1et5GcNetK-RA3FVksCf_5ChauRxVK3l2vJc,7234
2
- unittest_parametrize/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- unittest_parametrize-1.7.0.dist-info/licenses/LICENSE,sha256=Jn179RflkRZXhSCGt_D7asLy2Ex47C0WdBHxe0lBazk,1069
4
- unittest_parametrize-1.7.0.dist-info/METADATA,sha256=iD6hm8ej4zGlHDAvI_4WwPKVyIzS2-U_zrqPYDYOVSY,17807
5
- unittest_parametrize-1.7.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
- unittest_parametrize-1.7.0.dist-info/top_level.txt,sha256=4nLqNaGtBX8Ny36ZdFt37Gk-87hPtOvfdfZlTBi3OtU,21
7
- unittest_parametrize-1.7.0.dist-info/RECORD,,