|
35 | 35 | import _pytest
|
36 | 36 | from _pytest import nodes
|
37 | 37 | from _pytest._code import getfslineno
|
| 38 | +from _pytest._code import Source |
38 | 39 | from _pytest._code.code import FormattedExcinfo
|
39 | 40 | from _pytest._code.code import TerminalRepr
|
40 | 41 | from _pytest._io import TerminalWriter
|
@@ -864,13 +865,6 @@ def toterminal(self, tw: TerminalWriter) -> None:
|
864 | 865 | tw.line("%s:%d" % (os.fspath(self.filename), self.firstlineno + 1))
|
865 | 866 |
|
866 | 867 |
|
867 |
| -def fail_fixturefunc(fixturefunc, msg: str) -> NoReturn: |
868 |
| - fs, lineno = getfslineno(fixturefunc) |
869 |
| - location = f"{fs}:{lineno + 1}" |
870 |
| - source = _pytest._code.Source(fixturefunc) |
871 |
| - fail(msg + ":\n\n" + str(source.indent()) + "\n" + location, pytrace=False) |
872 |
| - |
873 |
| - |
874 | 868 | def call_fixture_func(
|
875 | 869 | fixturefunc: "_FixtureFunc[FixtureValue]", request: FixtureRequest, kwargs
|
876 | 870 | ) -> FixtureValue:
|
@@ -900,7 +894,13 @@ def _teardown_yield_fixture(fixturefunc, it) -> None:
|
900 | 894 | except StopIteration:
|
901 | 895 | pass
|
902 | 896 | else:
|
903 |
| - fail_fixturefunc(fixturefunc, "fixture function has more than one 'yield'") |
| 897 | + fs, lineno = getfslineno(fixturefunc) |
| 898 | + fail( |
| 899 | + f"fixture function has more than one 'yield':\n\n" |
| 900 | + f"{Source(fixturefunc).indent()}\n" |
| 901 | + f"{fs}:{lineno + 1}", |
| 902 | + pytrace=False, |
| 903 | + ) |
904 | 904 |
|
905 | 905 |
|
906 | 906 | def _eval_scope_callable(
|
|
0 commit comments