Skip to content

Commit 64da72b

Browse files
committed
fixtures: inline fail_fixturefunc
Doesn't add much.
1 parent 0bdb8e6 commit 64da72b

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/_pytest/fixtures.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import _pytest
3636
from _pytest import nodes
3737
from _pytest._code import getfslineno
38+
from _pytest._code import Source
3839
from _pytest._code.code import FormattedExcinfo
3940
from _pytest._code.code import TerminalRepr
4041
from _pytest._io import TerminalWriter
@@ -863,13 +864,6 @@ def toterminal(self, tw: TerminalWriter) -> None:
863864
tw.line("%s:%d" % (os.fspath(self.filename), self.firstlineno + 1))
864865

865866

866-
def fail_fixturefunc(fixturefunc, msg: str) -> NoReturn:
867-
fs, lineno = getfslineno(fixturefunc)
868-
location = f"{fs}:{lineno + 1}"
869-
source = _pytest._code.Source(fixturefunc)
870-
fail(msg + ":\n\n" + str(source.indent()) + "\n" + location, pytrace=False)
871-
872-
873867
def call_fixture_func(
874868
fixturefunc: "_FixtureFunc[FixtureValue]", request: FixtureRequest, kwargs
875869
) -> FixtureValue:
@@ -899,7 +893,13 @@ def _teardown_yield_fixture(fixturefunc, it) -> None:
899893
except StopIteration:
900894
pass
901895
else:
902-
fail_fixturefunc(fixturefunc, "fixture function has more than one 'yield'")
896+
fs, lineno = getfslineno(fixturefunc)
897+
fail(
898+
f"fixture function has more than one 'yield':\n\n"
899+
f"{Source(fixturefunc).indent()}\n"
900+
f"{fs}:{lineno + 1}",
901+
pytrace=False,
902+
)
903903

904904

905905
def _eval_scope_callable(

0 commit comments

Comments
 (0)