1818
1919from .common_mini_six import string_types
2020from .common_others import get_code_first_line , AUTO , qname , funcopy
21- from .common_pytest_marks import copy_pytest_marks , make_marked_parameter_value , remove_pytest_mark , filter_marks
22- from .common_pytest_lazy_values import lazy_value
21+ from .common_pytest_marks import copy_pytest_marks , make_marked_parameter_value , remove_pytest_mark , filter_marks , \
22+ get_param_argnames_as_list
23+ from .common_pytest_lazy_values import lazy_value , LazyTupleItem
2324from .common_pytest import safe_isclass , MiniMetafunc , is_fixture , get_fixture_name , inject_host , add_fixture_params
2425
2526from . import fixture
@@ -721,7 +722,7 @@ def _of_interest(x): # noqa
721722
722723
723724def get_current_case_id (request_or_item ,
724- argnames # type: str
725+ argnames # type: Union[Iterable[ str], str]
725726 ):
726727 """
727728 A helper function to return the current case id for a given `pytest` item (available in some hooks) or `request`
@@ -739,16 +740,23 @@ def get_current_case_id(request_or_item,
739740 except AttributeError :
740741 item = request_or_item
741742
743+ # process argnames
744+ if isinstance (argnames , string_types ):
745+ argnames = get_param_argnames_as_list (argnames )
746+ argnames_str = '_' .join (argnames ).replace (' ' , '' )
747+
742748 try :
743- # A LazyValue ?
744- lazy_val = item .callspec .params [argnames ]
749+ # A LazyValue or LazyTupleItem ?
750+ lazy_val = item .callspec .params [argnames [ 0 ] ]
745751 except KeyError :
746752 # No: A fixture union created by `parametrize_plus_decorate`
747753 main_fixture_style_template = "%s_%s"
748- fixture_union_name = main_fixture_style_template % (item .function .__name__ , argnames )
754+ fixture_union_name = main_fixture_style_template % (item .function .__name__ , argnames_str )
749755 return item .callspec .params [fixture_union_name ].get_alternative_id ()
750756 else :
751- # A lazyvalue - confirmed
757+ # A LazyValue or LazyTupleItem - confirmed.
758+ if isinstance (lazy_val , LazyTupleItem ):
759+ lazy_val = lazy_val .host
752760 return lazy_val .get_id ()
753761
754762
0 commit comments