MCPcopy
hub / github.com/pytest-dev/pytest / _teardown_yield_fixture

Function _teardown_yield_fixture

src/_pytest/fixtures.py:1009–1024  ·  view source on GitHub ↗

Execute the teardown of a fixture function by advancing the iterator after the yield and ensure the iteration ends (if not it means there is more than one yield in the function).

(fixturefunc, it)

Source from the content-addressed store, hash-verified

1007
1008
1009def _teardown_yield_fixture(fixturefunc, it) -> None:
1010 """Execute the teardown of a fixture function by advancing the iterator
1011 after the yield and ensure the iteration ends (if not it means there is
1012 more than one yield in the function)."""
1013 try:
1014 next(it)
1015 except StopIteration:
1016 pass
1017 else:
1018 fs, lineno = getfslineno(fixturefunc)
1019 fail(
1020 f"fixture function has more than one 'yield':\n\n"
1021 f"{Source(fixturefunc).indent()}\n"
1022 f"{fs}:{lineno + 1}",
1023 pytrace=False,
1024 )
1025
1026
1027def _eval_scope_callable(

Callers

nothing calls this directly

Calls 3

getfslinenoFunction · 0.90
SourceClass · 0.90
indentMethod · 0.80

Tested by

no test coverage detected