@@ -826,6 +826,8 @@ def __init__(self, function, fixtureinfo, config, cls=None, module=None):
826
826
self .cls = cls
827
827
self ._calls = []
828
828
self ._ids = py .builtin .set ()
829
+ self ._used_ids = []
830
+ self ._used_argvalues = []
829
831
830
832
def parametrize (self , argnames , argvalues , indirect = False , ids = None ,
831
833
scope = None ):
@@ -837,7 +839,7 @@ def parametrize(self, argnames, argvalues, indirect=False, ids=None,
837
839
:arg argnames: a comma-separated string denoting one or more argument
838
840
names, or a list/tuple of argument strings.
839
841
840
- :arg argvalues: The list of argvalues determines how often a
842
+ :arg argvalues: The list/generator of argvalues determines how often a
841
843
test is invoked with different argument values. If only one
842
844
argname was specified argvalues is a list of simple values. If N
843
845
argnames were specified, argvalues must be a list of N-tuples,
@@ -849,7 +851,7 @@ def parametrize(self, argnames, argvalues, indirect=False, ids=None,
849
851
function so that it can perform more expensive setups during the
850
852
setup phase of a test rather than at collection time.
851
853
852
- :arg ids: list of string ids, or a callable.
854
+ :arg ids: list of string ids, generator or a callable.
853
855
If strings, each is corresponding to the argvalues so that they are
854
856
part of the test id.
855
857
If callable, it should take one argument (a single argvalue) and return
@@ -869,6 +871,9 @@ def parametrize(self, argnames, argvalues, indirect=False, ids=None,
869
871
# at Function init
870
872
newkeywords = {}
871
873
unwrapped_argvalues = []
874
+ if not self ._used_argvalues :
875
+ self ._used_argvalues = argvalues = list (argvalues )
876
+
872
877
for i , argval in enumerate (argvalues ):
873
878
while isinstance (argval , MarkDecorator ):
874
879
newmark = MarkDecorator (argval .markname ,
@@ -900,6 +905,8 @@ def parametrize(self, argnames, argvalues, indirect=False, ids=None,
900
905
if callable (ids ):
901
906
idfn = ids
902
907
ids = None
908
+ if not self ._used_ids and ids :
909
+ self ._used_ids = ids = list (ids )
903
910
if ids and len (ids ) != len (argvalues ):
904
911
raise ValueError ('%d tests specified with %d ids' % (
905
912
len (argvalues ), len (ids )))
0 commit comments