Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc: Add documentation for parametrize_all_cases and get_all_cases #259

Merged
merged 5 commits into from Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions docs/api_reference.md
Expand Up @@ -257,8 +257,9 @@ CaseFilter(filter_function: Callable)
### `@parametrize_with_cases`

```python
CaseType = Union[Callable, Type, ModuleRef]
smarie marked this conversation as resolved.
Show resolved Hide resolved
@parametrize_with_cases(argnames: str,
cases: Union[Callable, Type, ModuleRef] = AUTO,
cases: Union[CaseType, List[CaseType]] = AUTO,
prefix: str = 'case_',
glob: str = None,
has_tag: Union[str, Iterable[str]] = None,
Expand All @@ -274,7 +275,7 @@ A decorator for test functions or fixtures, to parametrize them based on test ca

By default (`cases=AUTO`) the list of test cases is automatically drawn from the python module file named `test_<name>_cases.py` or if not found, `case_<name>.py`, where `test_<name>` is the current module name.

Finally, the `cases` argument also accepts an explicit case function, cases-containing class, module or module name; or a list of such elements. Note that both absolute and relative module names are suported.
Finally, the `cases` argument also accepts an explicit case function, cases-containing class, module or module name; or a list containing any mix of these elements. Note that both absolute and relative module names are supported.

Note that `@parametrize_with_cases` collection and parameter creation steps are strictly equivalent to [`get_all_cases`](#get_all_cases) + [`get_parametrize_args`](#get_parametrize_args). This can be handy for debugging purposes.

Expand Down Expand Up @@ -335,8 +336,9 @@ Note that you can get the same contents directly by using the [`current_cases`](
### `get_all_cases`

```python
CaseType = Union[Callable, Type, ModuleRef]
smarie marked this conversation as resolved.
Show resolved Hide resolved
def get_all_cases(parametrization_target: Callable,
cases: Union[Callable, Type, ModuleRef] = None,
cases: Union[CaseType, List[CaseType]] = None,
prefix: str = 'case_',
glob: str = None,
has_tag: Union[str, Iterable[str]] = None,
Expand Down
5 changes: 3 additions & 2 deletions src/pytest_cases/case_parametrizer_new.py
Expand Up @@ -56,6 +56,7 @@
from types import ModuleType # noqa

ModuleRef = Union[str, ModuleType, Literal[AUTO], Literal[THIS_MODULE]] # noqa
CaseType = Union[Callable, Type, ModuleRef]

except: # noqa
pass
Expand All @@ -65,7 +66,7 @@


def parametrize_with_cases(argnames, # type: Union[str, List[str], Tuple[str, ...]]
cases=AUTO, # type: Union[Callable, Type, ModuleRef]
cases=AUTO, # type: Union[CaseType, List[CaseType]]
prefix=CASE_PREFIX_FUN, # type: str
glob=None, # type: str
has_tag=None, # type: Any
Expand Down Expand Up @@ -206,7 +207,7 @@ def _glob_name_filter(case_fun):


def get_all_cases(parametrization_target, # type: Callable
cases=None, # type: Union[Callable, Type, ModuleRef]
cases=None, # type: Union[CaseType, List[CaseType]]
prefix=CASE_PREFIX_FUN, # type: str
glob=None, # type: str
has_tag=None, # type: Union[str, Iterable[str]]
Expand Down