fix regression with yield-based tests (hopefully)

This commit is contained in:
holger krekel
2011-01-14 13:30:36 +01:00
parent 2b750074f4
commit aea4d1bd7a
3 changed files with 55 additions and 2 deletions

View File

@@ -304,7 +304,9 @@ class FunctionMixin(PyobjMixin):
name = 'setup_method'
else:
name = 'setup_function'
if isinstance(self.parent, Instance):
if hasattr(self, '_preservedparent'):
obj = self._preservedparent
elif isinstance(self.parent, Instance):
obj = self.parent.newinstance()
self.obj = self._getobj()
else:
@@ -377,7 +379,8 @@ class Generator(FunctionMixin, PyCollectorMixin, pytest.Collector):
# invoke setup/teardown on popular request
# (induced by the common "test_*" naming shared with normal tests)
self.config._setupstate.prepare(self)
# see FunctionMixin.setup and test_setupstate_is_preserved_134
self._preservedparent = self.parent.obj
l = []
seen = {}
for i, x in enumerate(self.obj()):