def prepare(self, item: Item) -> None: """Setup objects along the collector chain to the item.""" # If a collector fails its setup, fail its entire subtree of items. # The setup is not retried for each item - the same exception is used. for col, (finalizers, prepare_exc) in self.stack.items(): if prepare_exc: raise prepare_exc needed_collectors = item.listchain() for col in needed_collectors[len(self.stack):]: assert col not in self.stack self.stack[col] = ([col.teardown], None) try: col.setup() except TEST_OUTCOME as e: self.stack[col] = (self.stack[col][0], e) raise e
def prepare(self, item: Item) -> None: """Setup objects along the collector chain to the item.""" # If a collector fails its setup, fail its entire subtree of items. # The setup is not retried for each item - the same exception is used. for col in self.stack: prepare_exc = col._store.get(self._prepare_exc_key, None) if prepare_exc: raise prepare_exc needed_collectors = item.listchain() for col in needed_collectors[len(self.stack) :]: assert col not in self.stack self.stack[col] = [col.teardown] try: col.setup() except TEST_OUTCOME as e: col._store[self._prepare_exc_key] = e raise e
def setup(self, item: Item) -> None: """Setup objects along the collector chain to the item.""" needed_collectors = item.listchain() # If a collector fails its setup, fail its entire subtree of items. # The setup is not retried for each item - the same exception is used. for col, (finalizers, exc) in self.stack.items(): assert col in needed_collectors, "previous item was not torn down properly" if exc: raise exc for col in needed_collectors[len(self.stack):]: assert col not in self.stack # Push onto the stack. self.stack[col] = ([col.teardown], None) try: col.setup() except TEST_OUTCOME as exc: self.stack[col] = (self.stack[col][0], exc) raise exc