Home / File/ test_helpers.py — flask Source File

test_helpers.py — flask Source File

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

File python ApplicationCore AppLifeCycle 7 imports 8 functions 13 classes

Entity Profile

Dependency Diagram

graph LR
  d5d22f74_a243_4ea9_9dfe_aaec71d26288["test_helpers.py"]
  ae09b50b_b5d6_a85f_ee35_4bca99dcf5dd["io"]
  d5d22f74_a243_4ea9_9dfe_aaec71d26288 --> ae09b50b_b5d6_a85f_ee35_4bca99dcf5dd
  bdc6911d_da67_3a1f_90cb_90f5e9f0603e["os"]
  d5d22f74_a243_4ea9_9dfe_aaec71d26288 --> bdc6911d_da67_3a1f_90cb_90f5e9f0603e
  da94d511_b8b8_a450_f67f_fc28ea9b648a["pytest"]
  d5d22f74_a243_4ea9_9dfe_aaec71d26288 --> da94d511_b8b8_a450_f67f_fc28ea9b648a
  9b468bc7_cc0b_fef2_ed71_07b4f027fb55["werkzeug.exceptions"]
  d5d22f74_a243_4ea9_9dfe_aaec71d26288 --> 9b468bc7_cc0b_fef2_ed71_07b4f027fb55
  8c762fc5_c0b6_0d4d_3889_896d80fbf225["flask"]
  d5d22f74_a243_4ea9_9dfe_aaec71d26288 --> 8c762fc5_c0b6_0d4d_3889_896d80fbf225
  20d75f81_b27e_d853_4ae3_b2739a584c68["flask.helpers"]
  d5d22f74_a243_4ea9_9dfe_aaec71d26288 --> 20d75f81_b27e_d853_4ae3_b2739a584c68
  eda0cf94_ef01_1441_96fa_d1dc0c43581a["flask.views"]
  d5d22f74_a243_4ea9_9dfe_aaec71d26288 --> eda0cf94_ef01_1441_96fa_d1dc0c43581a
  style d5d22f74_a243_4ea9_9dfe_aaec71d26288 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import io
import os

import pytest
import werkzeug.exceptions

import flask
from flask.helpers import get_debug_flag


class FakePath:
    """Fake object to represent a ``PathLike object``.

    This represents a ``pathlib.Path`` object in python 3.
    See: https://www.python.org/dev/peps/pep-0519/
    """

    def __init__(self, path):
        self.path = path

    def __fspath__(self):
        return self.path


class PyBytesIO:
    def __init__(self, *args, **kwargs):
        self._io = io.BytesIO(*args, **kwargs)

    def __getattr__(self, name):
        return getattr(self._io, name)


class TestSendfile:
    def test_send_file(self, app, req_ctx):
        rv = flask.send_file("static/index.html")
        assert rv.direct_passthrough
        assert rv.mimetype == "text/html"

        with app.open_resource("static/index.html") as f:
            rv.direct_passthrough = False
            assert rv.data == f.read()

        rv.close()

    def test_static_file(self, app, req_ctx):
        # Default max_age is None.

        # Test with static file handler.
        rv = app.send_static_file("index.html")
        assert rv.cache_control.max_age is None
        rv.close()

        # Test with direct use of send_file.
        rv = flask.send_file("static/index.html")
        assert rv.cache_control.max_age is None
        rv.close()

        app.config["SEND_FILE_MAX_AGE_DEFAULT"] = 3600

        # Test with static file handler.
// ... (324 more lines)

Subdomains

Dependencies

  • flask
  • flask.helpers
  • flask.views
  • io
  • os
  • pytest
  • werkzeug.exceptions

Frequently Asked Questions

What does test_helpers.py do?
test_helpers.py is a source file in the flask codebase, written in python. It belongs to the ApplicationCore domain, AppLifeCycle subdomain.
What functions are defined in test_helpers.py?
test_helpers.py defines 8 function(s): test_abort_no_app, test_abort_with_app, test_app_aborter_class, test_open_resource, test_open_resource_exceptions, test_open_resource_with_encoding, test_redirect_no_app, test_redirect_with_app.
What does test_helpers.py depend on?
test_helpers.py imports 7 module(s): flask, flask.helpers, flask.views, io, os, pytest, werkzeug.exceptions.
Where is test_helpers.py in the architecture?
test_helpers.py is located at tests/test_helpers.py (domain: ApplicationCore, subdomain: AppLifeCycle, directory: tests).

Analyze Your Own Codebase

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

Try Supermodel Free