Home / Function/ test_url_with_method() — flask Function Reference

test_url_with_method() — flask Function Reference

Architecture documentation for the test_url_with_method() function in test_helpers.py from the flask codebase.

Entity Profile

Dependency Diagram

graph TD
  642e1903_0685_b7bb_46eb_1c6b0959abbb["test_url_with_method()"]
  1e08bdec_29d2_c29b_db96_904133a45034["TestUrlFor"]
  642e1903_0685_b7bb_46eb_1c6b0959abbb -->|defined in| 1e08bdec_29d2_c29b_db96_904133a45034
  729b2b4d_9ff1_7f6f_84a8_82111621cd27["get()"]
  642e1903_0685_b7bb_46eb_1c6b0959abbb -->|calls| 729b2b4d_9ff1_7f6f_84a8_82111621cd27
  aef05fca_d92f_2cd0_3e6b_c4b46f7aef2d["post()"]
  642e1903_0685_b7bb_46eb_1c6b0959abbb -->|calls| aef05fca_d92f_2cd0_3e6b_c4b46f7aef2d
  style 642e1903_0685_b7bb_46eb_1c6b0959abbb fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_helpers.py lines 143–162

    def test_url_with_method(self, app, req_ctx):
        from flask.views import MethodView

        class MyView(MethodView):
            def get(self, id=None):
                if id is None:
                    return "List"
                return f"Get {id:d}"

            def post(self):
                return "Create"

        myview = MyView.as_view("myview")
        app.add_url_rule("/myview/", methods=["GET"], view_func=myview)
        app.add_url_rule("/myview/<int:id>", methods=["GET"], view_func=myview)
        app.add_url_rule("/myview/create", methods=["POST"], view_func=myview)

        assert flask.url_for("myview", _method="GET") == "/myview/"
        assert flask.url_for("myview", id=42, _method="GET") == "/myview/42"
        assert flask.url_for("myview", _method="POST") == "/myview/create"

Subdomains

Calls

Frequently Asked Questions

What does test_url_with_method() do?
test_url_with_method() is a function in the flask codebase, defined in tests/test_helpers.py.
Where is test_url_with_method() defined?
test_url_with_method() is defined in tests/test_helpers.py at line 143.
What does test_url_with_method() call?
test_url_with_method() calls 2 function(s): get, post.

Analyze Your Own Codebase

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

Try Supermodel Free