code: def test_context_refcounts(app, client):
      called = []
  
      @app.teardown_request
      def teardown_req(error=None):
          called.append("request")
  
      @app.teardown_appcontext
      def teardown_app(error=None):
          called.append("app")
  
      @app.route("/")
      def index():
          with app_ctx:
              with request_ctx:
                  pass
  
          assert flask.request.environ["werkzeug.request"] is not None
          return ""
  
      res = client.get("/")
      assert res.status_code == 200
      assert res.data == b""
      assert called == ["request", "app"]
  
file_path: flask/tests/test_appctx.py
imports: import pytest
  import flask
  from flask.globals import app_ctx
  from flask.globals import request_ctx
label_desc: Use image node_id 13 for calling a global function with example usage: test_context_refcounts(app, client) and returns: str