Home / File/ test_views.py — flask Source File

test_views.py — flask Source File

Architecture documentation for test_views.py, a python file in the flask codebase. 3 imports, 0 dependents.

File python ApplicationCore ExtensionRegistry 3 imports 14 functions 14 classes

Entity Profile

Dependency Diagram

graph LR
  dc72c3f0_27a2_eeb5_19d5_19d3385508ed["test_views.py"]
  da94d511_b8b8_a450_f67f_fc28ea9b648a["pytest"]
  dc72c3f0_27a2_eeb5_19d5_19d3385508ed --> da94d511_b8b8_a450_f67f_fc28ea9b648a
  c8ef0481_732f_584a_537b_20ea831e8fd0["werkzeug.http"]
  dc72c3f0_27a2_eeb5_19d5_19d3385508ed --> c8ef0481_732f_584a_537b_20ea831e8fd0
  eda0cf94_ef01_1441_96fa_d1dc0c43581a["flask.views"]
  dc72c3f0_27a2_eeb5_19d5_19d3385508ed --> eda0cf94_ef01_1441_96fa_d1dc0c43581a
  style dc72c3f0_27a2_eeb5_19d5_19d3385508ed fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import pytest
from werkzeug.http import parse_set_header

import flask.views


def common_test(app):
    c = app.test_client()

    assert c.get("/").data == b"GET"
    assert c.post("/").data == b"POST"
    assert c.put("/").status_code == 405
    meths = parse_set_header(c.open("/", method="OPTIONS").headers["Allow"])
    assert sorted(meths) == ["GET", "HEAD", "OPTIONS", "POST"]


def test_basic_view(app):
    class Index(flask.views.View):
        methods = ["GET", "POST"]

        def dispatch_request(self):
            return flask.request.method

    app.add_url_rule("/", view_func=Index.as_view("index"))
    common_test(app)


def test_method_based_view(app):
    class Index(flask.views.MethodView):
        def get(self):
            return "GET"

        def post(self):
            return "POST"

    app.add_url_rule("/", view_func=Index.as_view("index"))

    common_test(app)


def test_view_patching(app):
    class Index(flask.views.MethodView):
        def get(self):
            raise ZeroDivisionError

        def post(self):
            raise ZeroDivisionError

    class Other(Index):
        def get(self):
            return "GET"

        def post(self):
            return "POST"

    view = Index.as_view("index")
    view.view_class = Other
    app.add_url_rule("/", view_func=view)
    common_test(app)

// ... (201 more lines)

Subdomains

Dependencies

  • flask.views
  • pytest
  • werkzeug.http

Frequently Asked Questions

What does test_views.py do?
test_views.py is a source file in the flask codebase, written in python. It belongs to the ApplicationCore domain, ExtensionRegistry subdomain.
What functions are defined in test_views.py?
test_views.py defines 14 function(s): common_test, test_basic_view, test_endpoint_override, test_explicit_head, test_implicit_head, test_init_once, test_method_based_view, test_methods_var_inheritance, test_multiple_inheritance, test_remove_method_from_parent, and 4 more.
What does test_views.py depend on?
test_views.py imports 3 module(s): flask.views, pytest, werkzeug.http.
Where is test_views.py in the architecture?
test_views.py is located at tests/test_views.py (domain: ApplicationCore, subdomain: ExtensionRegistry, directory: tests).

Analyze Your Own Codebase

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

Try Supermodel Free