Skip to content

Commit 2fbb150

Browse files
author
Sylvain MARIE
committed
Minor: Docstring and type hints
1 parent fefb76c commit 2fbb150

File tree

3 files changed

+22
-20
lines changed

3 files changed

+22
-20
lines changed

pytest_cases/common_pytest_lazy_values.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -132,20 +132,6 @@ def __init__(self,
132132
id=None, # type: str # noqa
133133
marks=() # type: Union[Any, Sequence[Any]]
134134
):
135-
"""
136-
Creates a reference to a value getter, to be used in `parametrize_plus`.
137-
138-
A `lazy_value` is the same thing than a function-scoped fixture, except that the value getter function is not a
139-
fixture and therefore can neither be parametrized nor depend on fixtures. It should have no mandatory argument.
140-
141-
Note that a `lazy_value` can be included in a `pytest.param` without problem. In that case the id defined by
142-
`pytest.param` will take precedence over the one defined in `lazy_value` if any. The marks, however,
143-
will all be kept wherever they are defined.
144-
145-
:param valuegetter: a callable without mandatory arguments
146-
:param id: an optional id. Otherwise `valuegetter.__name__` will be used by default
147-
:param marks: optional marks. `valuegetter` marks will also be preserved.
148-
"""
149135
self.valuegetter = valuegetter
150136
self._id = id
151137
if isinstance(marks, (tuple, list, set)):
@@ -289,6 +275,20 @@ def lazy_value(valuegetter, # type: Callable[[], Any]
289275
id=None, # type: str # noqa
290276
marks=() # type: Union[Any, Sequence[Any]]
291277
):
278+
"""
279+
Creates a reference to a value getter, to be used in `parametrize_plus`.
280+
281+
A `lazy_value` is the same thing than a function-scoped fixture, except that the value getter function is not a
282+
fixture and therefore can neither be parametrized nor depend on fixtures. It should have no mandatory argument.
283+
284+
Note that a `lazy_value` can be included in a `pytest.param` without problem. In that case the id defined by
285+
`pytest.param` will take precedence over the one defined in `lazy_value` if any. The marks, however,
286+
will all be kept wherever they are defined.
287+
288+
:param valuegetter: a callable without mandatory arguments
289+
:param id: an optional id. Otherwise `valuegetter.__name__` will be used by default
290+
:param marks: optional marks. `valuegetter` marks will also be preserved.
291+
"""
292292
return LazyValue(valuegetter, id=id, marks=marks)
293293

294294

pytest_cases/fixture_core2.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030

3131
def param_fixture(argname, # type: str
32-
argvalues, # type: Sequence[Any]
32+
argvalues, # type: Iterable[Any]
3333
autouse=False, # type: bool
3434
ids=None, # type: Union[Callable, List[str]]
3535
scope="function", # type: str
@@ -126,8 +126,8 @@ def __param_fixture(request):
126126
return fix
127127

128128

129-
def param_fixtures(argnames,
130-
argvalues,
129+
def param_fixtures(argnames, # type: str
130+
argvalues, # type: Iterable[Any]
131131
autouse=False, # type: bool
132132
ids=None, # type: Union[Callable, List[str]]
133133
scope="function", # type: str
@@ -284,6 +284,8 @@ def fixture_plus(scope="function", # type: str
284284
- it supports a new argument `unpack_into` where you can provide names for fixtures where to unpack this fixture
285285
into.
286286
287+
As a consequence it does not support the `params` and `ids` arguments anymore.
288+
287289
:param scope: the scope for which this fixture is shared, one of "function" (default), "class", "module" or
288290
"session".
289291
:param autouse: if True, the fixture func is activated for all tests that can see it. If False (the default) then

pytest_cases/fixture_parametrize_plus.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def _new_fixture(**all_fixtures):
119119

120120
class fixture_ref(object): # noqa
121121
"""
122-
A reference to a fixture, to be used in `parametrize_plus`.
122+
A reference to a fixture, to be used in `@parametrize_plus`.
123123
You can create it from a fixture name or a fixture object (function).
124124
"""
125125
__slots__ = 'fixture',
@@ -273,8 +273,8 @@ def get(cls, style # type: str
273273
_IDGEN = object()
274274

275275

276-
def parametrize_plus(argnames=None,
277-
argvalues=None,
276+
def parametrize_plus(argnames=None, # type: str
277+
argvalues=None, # type: Iterable[Any]
278278
indirect=False, # type: bool
279279
ids=None, # type: Union[Callable, List[str]]
280280
idstyle='explicit', # type: str

0 commit comments

Comments
 (0)