Skip to content

Commit 4be90a2

Browse files
author
Sylvain MARIE
committed
Added missing deprecation warning on @cases_generator. Fixes #124
1 parent 7a81026 commit 4be90a2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pytest_cases/case_funcs_legacy.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,11 @@ def cases_generator(names=None, # type: Union[str, Callable[[Any], str
105105
case_func=DECORATED, # noqa
106106
**param_ranges # type: Iterable[Any]
107107
):
108-
"""
108+
""" DEPRECATED - use `@parametrize(**<param_ranges>, idgen=<names>)` instead
109+
110+
Note that `@cases_generator` (legacy api) does not work correctly with `@parametrize_with_cases` (new api). Only
111+
`@cases_data` (legacy api) is compliant. See https://github.com/smarie/python-pytest-cases/issues/124
112+
109113
Decorator to declare a case function as being a cases generator. `param_ranges` should be a named list of parameter
110114
ranges to explore to generate the cases.
111115
@@ -133,6 +137,9 @@ def cases_generator(names=None, # type: Union[str, Callable[[Any], str
133137
function so they should have names the underlying function can handle.
134138
:return:
135139
"""
140+
warn("`@case_generator` is deprecated. Please use `@parametrize(**<param_ranges>, idgen=<names>)` instead.",
141+
category=DeprecationWarning, stacklevel=2)
142+
136143
kwarg_values = list(product(*param_ranges.values()))
137144
setattr(case_func, _GENERATOR_FIELD, (names, param_ranges.keys(), kwarg_values))
138145

0 commit comments

Comments
 (0)