summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRan Benita <ran@unusedvar.com>2021-01-31 12:14:06 +0200
committerRan Benita <ran@unusedvar.com>2021-02-06 20:46:08 +0200
commitf42b68ccaa4a64b3f7ef1cfcff50b4f39b63ceb9 (patch)
tree551bb6ca1e2d4ff5a1905619a23a28af481b5a98 /src
parentf674f6da9fec826bc8c4e08781e7309322fc12cc (diff)
downloadpytest-f42b68ccaa4a64b3f7ef1cfcff50b4f39b63ceb9.tar.gz
runner: rename SetupState.prepare -> setup
This is the usual terminology we use, and matches better with `teardown_exact()` and `pytest_runtest_setup()`.
Diffstat (limited to 'src')
-rw-r--r--src/_pytest/fixtures.py2
-rw-r--r--src/_pytest/runner.py22
2 files changed, 12 insertions, 12 deletions
diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py
index 269369642..40b482d04 100644
--- a/src/_pytest/fixtures.py
+++ b/src/_pytest/fixtures.py
@@ -372,7 +372,7 @@ def _fill_fixtures_impl(function: "Function") -> None:
fi = fm.getfixtureinfo(function.parent, function.obj, None)
function._fixtureinfo = fi
request = function._request = FixtureRequest(function, _ispytest=True)
- fm.session._setupstate.prepare(function)
+ fm.session._setupstate.setup(function)
request._fillfixtures()
# Prune out funcargs for jstests.
newfuncargs = {}
diff --git a/src/_pytest/runner.py b/src/_pytest/runner.py
index 124cf531a..153b134fe 100644
--- a/src/_pytest/runner.py
+++ b/src/_pytest/runner.py
@@ -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: