5
5
Handy functions for testing code.
6
6
7
7
Requires `pytest <https://docs.pytest.org/en/stable/>`_ to be installed.
8
+
9
+ .. versionadded:: 0.4.9
8
10
"""
9
11
#
10
12
# Copyright © 2020 Dominic Davis-Foster <[email protected] >
38
40
# this package
39
41
from domdf_python_tools .utils import Len
40
42
43
+ __all__ = [
44
+ "generate_truthy_values" ,
45
+ "generate_falsy_values" ,
46
+ "testing_boolean_values" ,
47
+ "whitespace" ,
48
+ "whitespace_perms_list" ,
49
+ "whitespace_perms" ,
50
+ "count" ,
51
+ ]
52
+
41
53
42
54
def generate_truthy_values (extra_truthy : Sequence = (), ratio : float = 1 ) -> Iterator [Any ]:
43
55
"""
@@ -47,6 +59,8 @@ def generate_truthy_values(extra_truthy: Sequence = (), ratio: float = 1) -> Ite
47
59
48
60
:param extra_truthy: Additional values that should be considered :py:obj:`True`.
49
61
:param ratio: The ratio of the number of values to select to the total number of values.
62
+
63
+ .. versionadded:: 0.4.9
50
64
"""
51
65
52
66
truthy_values = [
@@ -81,6 +95,8 @@ def generate_falsy_values(extra_falsy: Sequence = (), ratio: float = 1) -> Itera
81
95
82
96
:param extra_falsy: Additional values that should be considered :py:obj:`True`.
83
97
:param ratio: The ratio of the number of values to select to the total number of values.
98
+
99
+ .. versionadded:: 0.4.9
84
100
"""
85
101
86
102
falsy_values = [
@@ -124,6 +140,8 @@ def testing_boolean_values(
124
140
:param extra_truthy: Additional values that should be considered :py:obj:`True`.
125
141
:param extra_falsy: Additional values that should be considered :py:obj:`False`.
126
142
:param ratio: The ratio of the number of values to select to the total number of values.
143
+
144
+ .. versionadded:: 0.4.9
127
145
"""
128
146
129
147
truthy = generate_truthy_values (extra_truthy , ratio )
@@ -157,6 +175,8 @@ def whitespace_perms(ratio: float = 0.5) -> MarkDecorator:
157
175
The single parametrized argument is ``char``.
158
176
159
177
:param ratio: The ratio of the number of permutations to select to the total number of permutations.
178
+
179
+ .. versionadded:: 0.4.9
160
180
"""
161
181
162
182
perms = whitespace_perms_list ()
@@ -173,6 +193,8 @@ def count(stop: int, start: int = 0, step: int = 1) -> MarkDecorator:
173
193
:param stop: The stop value passed to :class:`range`.
174
194
:param start: The start value passed to :class:`range`.
175
195
:param step: The step passed to :class:`range`.
196
+
197
+ .. versionadded:: 0.4.9
176
198
"""
177
199
178
200
return pytest .mark .parametrize ("count" , range (start , stop , step ))
0 commit comments