@@ -421,8 +421,9 @@ def case_to_argvalues(host_class_or_module, # type: Union[Type, ModuleType]
421421 If `case_fun` requires at least on fixture, a fixture will be created if not yet present, and a `fixture_ref` will
422422 be returned.
423423
424- If `case_fun` is a parametrized case, one `lazy_value` with a partialized version will be created for each parameter
425- combination.
424+ If `case_fun` is a parametrized case, (NEW since 3.0.0) a fixture will be created if not yet present,
425+ and a `fixture_ref` will be returned. (OLD < 3.0.0) one `lazy_value` with a partialized version will be created
426+ for each parameter combination.
426427
427428 Otherwise, `case_fun` represents a single case: in that case a single `lazy_value` is returned.
428429
@@ -734,12 +735,27 @@ def extract_cases_from_class(cls,
734735 ):
735736 # type: (...) -> List[Callable]
736737 """
738+ Collects all case functions (methods matching ``case_fun_prefix``) in class ``cls``.
737739
738- :param cls:
739- :param check_name:
740- :param case_fun_prefix:
741- :param _case_param_factory:
742- :return:
740+ Parameters
741+ ----------
742+ cls : Type
743+ A class where to look for case functions. All methods matching ``prefix`` will be returned.
744+
745+ check_name : bool
746+ If this is ``True`` and class name does not contain the string ``Case``, the class will not be inspected and
747+ an empty list will be returned.
748+
749+ case_fun_prefix : str
750+ A prefix that case functions (class methods) must match to be collected.
751+
752+ _case_param_factory :
753+ Legacy. Not used.
754+
755+ Returns
756+ -------
757+ cases_lst : List[Callable]
758+ A list of collected case functions (class methods).
743759 """
744760 if is_case_class (cls , check_name = check_name ):
745761 # see from _pytest.python import pytest_pycollect_makeitem
@@ -769,7 +785,7 @@ def extract_cases_from_class(cls,
769785 return []
770786
771787
772- def extract_cases_from_module (module , # type: ModuleRef
788+ def extract_cases_from_module (module , # type: Union[str, ModuleRef]
773789 package_name = None , # type: str
774790 case_fun_prefix = CASE_PREFIX_FUN , # type: str
775791 _case_param_factory = None
@@ -782,10 +798,27 @@ def extract_cases_from_module(module, # type: ModuleRe
782798 See also `_pytest.python.PyCollector.collect` and `_pytest.python.PyCollector._makeitem` and
783799 `_pytest.python.pytest_pycollect_makeitem`: we could probably do this in a better way in pytest_pycollect_makeitem
784800
785- :param module:
786- :param package_name:
787- :param _case_param_factory:
788- :return:
801+ Parameters
802+ ----------
803+ module : Union[str, ModuleRef]
804+ A module where to look for case functions. All functions in the module matching ``prefix`` will be
805+ returned. In addition, all classes in the module with ``Case`` in their name will be inspected. For each of
806+ them, all methods matching ``prefix`` will be returned too.
807+
808+ package_name : Optional[str], default: None
809+ If ``module`` is provided as a string, this is a mandatory package full qualified name (e.g. ``a.b.c``) where
810+ to import the module from.
811+
812+ case_fun_prefix : str
813+ A prefix that case functions (including class methods) must match to be collected.
814+
815+ _case_param_factory :
816+ Legacy. Not used.
817+
818+ Returns
819+ -------
820+ cases : List[Callable]
821+ A list of case functions
789822 """
790823 # optionally import module if passed as module name string
791824 if isinstance (module , string_types ):
@@ -805,12 +838,30 @@ def _extract_cases_from_module_or_class(module=None, # type
805838 cls = None , # type: Type
806839 case_fun_prefix = CASE_PREFIX_FUN , # type: str
807840 _case_param_factory = None
808- ):
841+ ): # type: (...) -> List[Callable]
809842 """
843+ Extracts all case functions from `module` or `cls` (only one non-None must be provided).
810844
811- :param module:
812- :param _case_param_factory:
813- :return:
845+ Parameters
846+ ----------
847+ module : Optional[ModuleRef], default: None
848+ A module where to look for case functions. All functions in the module matching ``prefix`` will be
849+ returned. In addition, all classes in the module with ``Case`` in their name will be inspected. For each of
850+ them, all methods matching ``prefix`` will be returned too.
851+
852+ cls : Optional[Type], default: None
853+ A class where to look for case functions. All methods matching ``prefix`` will be returned.
854+
855+ case_fun_prefix : str
856+ A prefix that case functions (including class methods) must match to be collected.
857+
858+ _case_param_factory :
859+ Legacy. Not used.
860+
861+ Returns
862+ -------
863+ cases : List[Callable]
864+ A list of case functions
814865 """
815866 if not ((cls is None ) ^ (module is None )):
816867 raise ValueError ("Only one of cls or module should be provided" )
@@ -897,6 +948,7 @@ def _of_interest(x): # noqa
897948 % (m , cases_dct [co_firstlineno ]))
898949 cases_dct [co_firstlineno ] = m
899950 else :
951+ # Not used anymore
900952 # Legacy usage where the cases generators were expanded here and inserted with a virtual line no
901953 _case_param_factory (m , co_firstlineno , cases_dct )
902954
0 commit comments