Home / File/ test_signals.py — flask Source File

test_signals.py — flask Source File

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

Entity Profile

Dependency Diagram

graph LR
  a3094b63_9b33_613c_f8a0_440ab19800e5["test_signals.py"]
  8c762fc5_c0b6_0d4d_3889_896d80fbf225["flask"]
  a3094b63_9b33_613c_f8a0_440ab19800e5 --> 8c762fc5_c0b6_0d4d_3889_896d80fbf225
  style a3094b63_9b33_613c_f8a0_440ab19800e5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import flask


def test_template_rendered(app, client):
    @app.route("/")
    def index():
        return flask.render_template("simple_template.html", whiskey=42)

    recorded = []

    def record(sender, template, context):
        recorded.append((template, context))

    flask.template_rendered.connect(record, app)
    try:
        client.get("/")
        assert len(recorded) == 1
        template, context = recorded[0]
        assert template.name == "simple_template.html"
        assert context["whiskey"] == 42
    finally:
        flask.template_rendered.disconnect(record, app)


def test_before_render_template():
    app = flask.Flask(__name__)

    @app.route("/")
    def index():
        return flask.render_template("simple_template.html", whiskey=42)

    recorded = []

    def record(sender, template, context):
        context["whiskey"] = 43
        recorded.append((template, context))

    flask.before_render_template.connect(record, app)
    try:
        rv = app.test_client().get("/")
        assert len(recorded) == 1
        template, context = recorded[0]
        assert template.name == "simple_template.html"
        assert context["whiskey"] == 43
        assert rv.data == b"<h1>43</h1>"
    finally:
        flask.before_render_template.disconnect(record, app)


def test_request_signals():
    app = flask.Flask(__name__)
    calls = []

    def before_request_signal(sender):
        calls.append("before-signal")

    def after_request_signal(sender, response):
        assert response.data == b"stuff"
        calls.append("after-signal")

// ... (122 more lines)

Subdomains

Dependencies

  • flask

Frequently Asked Questions

What does test_signals.py do?
test_signals.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_signals.py?
test_signals.py defines 7 function(s): test_appcontext_signals, test_appcontext_tearing_down_signal, test_before_render_template, test_flash_signal, test_request_exception_signal, test_request_signals, test_template_rendered.
What does test_signals.py depend on?
test_signals.py imports 1 module(s): flask.
Where is test_signals.py in the architecture?
test_signals.py is located at tests/test_signals.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