MCPcopy Create free account
hub / github.com/pytest-dev/pytest / finish

Method finish

src/_pytest/fixtures.py:1017–1038  ·  view source on GitHub ↗
(self, request: SubRequest)

Source from the content-addressed store, hash-verified

1015 self._finalizers.append(finalizer)
1016
1017 def finish(self, request: SubRequest) -> None:
1018 exc = None
1019 try:
1020 while self._finalizers:
1021 try:
1022 func = self._finalizers.pop()
1023 func()
1024 except BaseException as e:
1025 # XXX Only first exception will be seen by user,
1026 # ideally all should be reported.
1027 if exc is None:
1028 exc = e
1029 if exc:
1030 raise exc
1031 finally:
1032 hook = self._fixturemanager.session.gethookproxy(request.node.path)
1033 hook.pytest_fixture_post_finalizer(fixturedef=self, request=request)
1034 # Even if finalization fails, we invalidate the cached fixture
1035 # value and remove all finalizers because they may be bound methods
1036 # which will keep instances alive.
1037 self.cached_result = None
1038 self._finalizers = []
1039
1040 def execute(self, request: SubRequest) -> FixtureValue:
1041 # Get required arguments and register our own finish()

Callers 2

executeMethod · 0.95
_schedule_finalizersMethod · 0.80

Calls 3

popMethod · 0.80
funcFunction · 0.70
gethookproxyMethod · 0.45

Tested by

no test coverage detected