code: def test_streaming_with_context_and_custom_close(self, app, client):
      called = []
  
      class Wrapper:
          def __init__(self, gen):
              self._gen = gen
  
          def __iter__(self):
              return self
  
          def close(self):
              called.append(42)
  
          def __next__(self):
              return next(self._gen)
  
          next = __next__
  
      @app.route("/")
      def index():
          def generate():
              yield "Hello "
              yield flask.request.args["name"]
              yield "!"
  
          return flask.Response(
              flask.stream_with_context(Wrapper(generate()))
          )
  
      rv = client.get("/?name=World")
      assert rv.data == b"Hello World!"
      assert called == [42]
  
imports: import io
  import os
  import pytest
  import werkzeug.exceptions
  import flask
  from flask.helpers import get_debug_flag
label_desc: Use image node_id 3 for calling the TestStreaming obj's underlying member method code with example usage: obj.test_streaming_with_context_and_custom_close(app, client) and returns: flask, self, next