Path 1: 580 calls (0.99)

None (543) ZeroDivisionError (12) TypeError (5) KeyError (4) ValueError (2) BadRequestKeyError (2) Exception (2) TestGenericHandlers.Custom (2) Keyboa...

1def pop(self, exc: BaseException | None = _sentinel) -> None:  # type: ignore
2        """Pops the app context."""
3        try:
4            if len(self._cv_tokens) == 1:
5                if exc is _sentinel:
6                    exc = sys.exc_info()[1]
7                self.app.do_teardown_appcontext(exc)
8        finally:
9            ctx = _cv_app.get()
10            _cv_app.reset(self._cv_tokens.pop())
11
12        if ctx is not self:
13            raise AssertionError(
14                f"Popped wrong app context. ({ctx!r} instead of {self!r})"
15            )
16
17        appcontext_popped.send(self.app, _async_wrapper=self.app.ensure_sync)
            

Path 2: 8 calls (0.01)

None (8)

1def pop(self, exc: BaseException | None = _sentinel) -> None:  # type: ignore
2        """Pops the app context."""
3        try:
4            if len(self._cv_tokens) == 1:
5                if exc is _sentinel:
6                    exc = sys.exc_info()[1]
7                self.app.do_teardown_appcontext(exc)
8        finally:
9            ctx = _cv_app.get()
10            _cv_app.reset(self._cv_tokens.pop())
11
12        if ctx is not self:
13            raise AssertionError(
14                f"Popped wrong app context. ({ctx!r} instead of {self!r})"
15            )
16
17        appcontext_popped.send(self.app, _async_wrapper=self.app.ensure_sync)