Skip to content

Commit 318b6a0

Browse files
author
Sylvain MARIE
committed
Minor improvement of get_id on LazyTuple
1 parent f168cd1 commit 318b6a0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pytest_cases/common_pytest_lazy_values.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,11 @@ def __len__(self):
272272

273273
def get_id(self):
274274
"""return the id to use by pytest"""
275-
return self.value.get_id()
275+
if self.retrieved:
276+
raise ValueError("id is lost once the tuple has been retrieved, this is ok since at this stage it should "
277+
"not be needed anymore...")
278+
else:
279+
return self.value.get_id()
276280

277281
def get(self):
278282
""" Call the underlying value getter, then return the tuple (not self) """
@@ -354,7 +358,7 @@ def clone(self, remove_int_base=False):
354358
# return a type(self) (LazyValue or subclass)
355359
return _LazyValue.clone(self)
356360
else:
357-
# return a _LazyValue
361+
# return a _LazyValue without the int base from _LazyValueBase
358362
return _LazyValue.copy_from(self)
359363

360364
class LazyTupleItem(_LazyTupleItem, _LazyValueBase):
@@ -365,7 +369,7 @@ def clone(self, remove_int_base=False):
365369
# return a type(self) (LazyTupleItem or subclass)
366370
return _LazyTupleItem.clone(self)
367371
else:
368-
# return a _LazyTupleItem
372+
# return a _LazyTupleItem without the int base from _LazyValueBase
369373
return _LazyTupleItem.copy_from(self)
370374

371375

0 commit comments

Comments
 (0)