coincidence.params
pytest.mark.parametrize decorators.
Functions:
|
Returns a pytest.mark.parametrize decorator which provides a list of numbers between |
|
Returns a pytest.mark.parametrize decorator which provides permutations of whitespace. |
|
Returns a pytest.mark.parametrize decorator which provides a list of strings, integers and booleans, and the boolean representations of them. |
|
Specify a parameter in pytest.mark.parametrize calls or parametrized fixtures. |
|
Return a list of parametrized version numbers. |
-
count(stop, start=0, step=1)[source] Returns a pytest.mark.parametrize decorator which provides a list of numbers between
startandstopwith an interval ofstep.The single parametrized argument is
count.
-
whitespace_perms(ratio=0.5)[source] Returns a pytest.mark.parametrize decorator which provides permutations of whitespace.
For this function whitespace is only
␣\n\t\r.Not all permutations are returned, as there are a lot of them; instead a random selection of the permutations is returned. By default ½ of the permutations are returned, but this can be configured using the
ratioargument.The single parametrized argument is
char.- Parameters
ratio (
float) – The ratio of the number of permutations to select to the total number of permutations. Default0.5.- Return type
MarkDecorator
-
testing_boolean_values(extra_truthy=(), extra_falsy=(), ratio=1)[source] Returns a pytest.mark.parametrize decorator which provides a list of strings, integers and booleans, and the boolean representations of them.
The parametrized arguments are
boolean_stringfor the input value, andexpected_booleanfor the expected output.Optionally, a random selection of the values can be returned using the
ratioargument.
-
param(*values, marks=(), id=None, idx=None, key=None)[source] Specify a parameter in pytest.mark.parametrize calls or parametrized fixtures.
Examples:
@pytest.mark.parametrize("test_input, expected", [ ("3+5", 8), param("6*9", 42, marks=pytest.mark.xfail), param("2**2", 4, idx=0), param("3**2", 9, id="3^2"), param("sqrt(9)", 3, key=itemgetter(0)), ]) def test_eval(test_input, expected): assert eval (test_input) == expected
New in version 0.4.0.
- Parameters
*values (
~_T) – Variable args of the values of the parameter set, in order.marks (
Union[MarkDecorator,Collection[Union[MarkDecorator,Mark]]]) – A single mark or a list of marks to be applied to this parameter set. Default().id (
Optional[str]) – The id to attribute to this parameter set. DefaultNone.idx (
Optional[int]) – The index of the value in*valuesto use as the id. DefaultNone.key (
Optional[Callable[[Tuple[~_T, …]],str]]) – A callable which is givenvalues(as atuple) and returns the value to use as the id. DefaultNone.
- Return type
ParameterSet- Overloads
-
parametrized_versions(*versions, reasons=())[source] Return a list of parametrized version numbers.
Examples:
@pytest.mark.parametrize( "version", parametrized_versions( 3.6, 3.7, 3.8, reason="Output differs on each version.", ), ) def test_something(version: str): pass
@pytest.fixture( params=parametrized_versions( 3.6, 3.7, 3.8, reason="Output differs on each version.", ), ) def version(request): return request.param def test_something(version: str): pass
New in version 0.4.0.
- Parameters
- Return type
List[ParameterSet]