runner: rename SetupState.prepare -> setup
This is the usual terminology we use, and matches better with `teardown_exact()` and `pytest_runtest_setup()`.
This commit is contained in:
@@ -151,7 +151,7 @@ def show_test_item(item: Item) -> None:
|
||||
|
||||
def pytest_runtest_setup(item: Item) -> None:
|
||||
_update_current_test_var(item, "setup")
|
||||
item.session._setupstate.prepare(item)
|
||||
item.session._setupstate.setup(item)
|
||||
|
||||
|
||||
def pytest_runtest_call(item: Item) -> None:
|
||||
@@ -417,7 +417,7 @@ class SetupState:
|
||||
|
||||
[]
|
||||
|
||||
During the setup phase of item1, prepare(item1) is called. What it does
|
||||
During the setup phase of item1, setup(item1) is called. What it does
|
||||
is:
|
||||
|
||||
push session to stack, run session.setup()
|
||||
@@ -441,7 +441,7 @@ class SetupState:
|
||||
|
||||
[session]
|
||||
|
||||
During the setup phase of item2, prepare(item2) is called. What it does
|
||||
During the setup phase of item2, setup(item2) is called. What it does
|
||||
is:
|
||||
|
||||
push mod2 to stack, run mod2.setup()
|
||||
@@ -477,16 +477,16 @@ class SetupState:
|
||||
],
|
||||
] = {}
|
||||
|
||||
def prepare(self, item: Item) -> None:
|
||||
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, prepare_exc) in self.stack.items():
|
||||
for col, (finalizers, exc) in self.stack.items():
|
||||
assert col in needed_collectors, "previous item was not torn down properly"
|
||||
if prepare_exc:
|
||||
raise prepare_exc
|
||||
if exc:
|
||||
raise exc
|
||||
|
||||
for col in needed_collectors[len(self.stack) :]:
|
||||
assert col not in self.stack
|
||||
@@ -494,9 +494,9 @@ class SetupState:
|
||||
self.stack[col] = ([col.teardown], None)
|
||||
try:
|
||||
col.setup()
|
||||
except TEST_OUTCOME as e:
|
||||
self.stack[col] = (self.stack[col][0], e)
|
||||
raise e
|
||||
except TEST_OUTCOME as exc:
|
||||
self.stack[col] = (self.stack[col][0], exc)
|
||||
raise exc
|
||||
|
||||
def addfinalizer(self, finalizer: Callable[[], object], node: Node) -> None:
|
||||
"""Attach a finalizer to the given node.
|
||||
@@ -520,7 +520,7 @@ class SetupState:
|
||||
while self.stack:
|
||||
if list(self.stack.keys()) == needed_collectors[: len(self.stack)]:
|
||||
break
|
||||
node, (finalizers, prepare_exc) = self.stack.popitem()
|
||||
node, (finalizers, _) = self.stack.popitem()
|
||||
while finalizers:
|
||||
fin = finalizers.pop()
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user