Home / Class/ TestGreenletContextCopying Class — flask Architecture

TestGreenletContextCopying Class — flask Architecture

Architecture documentation for the TestGreenletContextCopying class in test_reqctx.py from the flask codebase.

Entity Profile

Dependency Diagram

graph TD
  d3571f99_30e7_c391_939e_411db4c2011d["TestGreenletContextCopying"]
  aea65cbf_db83_bd4f_d83f_1a35ae104254["test_reqctx.py"]
  d3571f99_30e7_c391_939e_411db4c2011d -->|defined in| aea65cbf_db83_bd4f_d83f_1a35ae104254
  7fdf2a75_369a_3acf_8a49_51d83796e30f["test_greenlet_context_copying()"]
  d3571f99_30e7_c391_939e_411db4c2011d -->|method| 7fdf2a75_369a_3acf_8a49_51d83796e30f
  b11af580_8689_b9bf_e560_3798d24f4253["test_greenlet_context_copying_api()"]
  d3571f99_30e7_c391_939e_411db4c2011d -->|method| b11af580_8689_b9bf_e560_3798d24f4253

Relationship Graph

Source Code

tests/test_reqctx.py lines 149–202

class TestGreenletContextCopying:
    def test_greenlet_context_copying(self, app, client):
        greenlets = []

        @app.route("/")
        def index():
            flask.session["fizz"] = "buzz"
            ctx = app_ctx.copy()

            def g():
                assert not flask.request
                assert not flask.current_app
                with ctx:
                    assert flask.request
                    assert flask.current_app == app
                    assert flask.request.path == "/"
                    assert flask.request.args["foo"] == "bar"
                    assert flask.session.get("fizz") == "buzz"
                assert not flask.request
                return 42

            greenlets.append(greenlet(g))
            return "Hello World!"

        rv = client.get("/?foo=bar")
        assert rv.data == b"Hello World!"

        result = greenlets[0].run()
        assert result == 42

    def test_greenlet_context_copying_api(self, app, client):
        greenlets = []

        @app.route("/")
        def index():
            flask.session["fizz"] = "buzz"

            @flask.copy_current_request_context
            def g():
                assert flask.request
                assert flask.current_app == app
                assert flask.request.path == "/"
                assert flask.request.args["foo"] == "bar"
                assert flask.session.get("fizz") == "buzz"
                return 42

            greenlets.append(greenlet(g))
            return "Hello World!"

        rv = client.get("/?foo=bar")
        assert rv.data == b"Hello World!"

        result = greenlets[0].run()
        assert result == 42

Frequently Asked Questions

What is the TestGreenletContextCopying class?
TestGreenletContextCopying is a class in the flask codebase, defined in tests/test_reqctx.py.
Where is TestGreenletContextCopying defined?
TestGreenletContextCopying is defined in tests/test_reqctx.py at line 149.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free