Home / File/ test_config.py — flask Source File

test_config.py — flask Source File

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

File python ApplicationCore ExtensionRegistry 4 imports 18 functions 4 classes

Entity Profile

Dependency Diagram

graph LR
  af09ffc0_0dff_d9d9_7274_4611c3d0d0e6["test_config.py"]
  24c75b54_2419_4c05_11fb_668c1d1c4ac5["json"]
  af09ffc0_0dff_d9d9_7274_4611c3d0d0e6 --> 24c75b54_2419_4c05_11fb_668c1d1c4ac5
  bdc6911d_da67_3a1f_90cb_90f5e9f0603e["os"]
  af09ffc0_0dff_d9d9_7274_4611c3d0d0e6 --> bdc6911d_da67_3a1f_90cb_90f5e9f0603e
  da94d511_b8b8_a450_f67f_fc28ea9b648a["pytest"]
  af09ffc0_0dff_d9d9_7274_4611c3d0d0e6 --> da94d511_b8b8_a450_f67f_fc28ea9b648a
  8c762fc5_c0b6_0d4d_3889_896d80fbf225["flask"]
  af09ffc0_0dff_d9d9_7274_4611c3d0d0e6 --> 8c762fc5_c0b6_0d4d_3889_896d80fbf225
  style af09ffc0_0dff_d9d9_7274_4611c3d0d0e6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import json
import os

import pytest

import flask

# config keys used for the TestConfig
TEST_KEY = "foo"
SECRET_KEY = "config"


def common_object_test(app):
    assert app.secret_key == "config"
    assert app.config["TEST_KEY"] == "foo"
    assert "TestConfig" not in app.config


def test_config_from_pyfile():
    app = flask.Flask(__name__)
    app.config.from_pyfile(f"{__file__.rsplit('.', 1)[0]}.py")
    common_object_test(app)


def test_config_from_object():
    app = flask.Flask(__name__)
    app.config.from_object(__name__)
    common_object_test(app)


def test_config_from_file_json():
    app = flask.Flask(__name__)
    current_dir = os.path.dirname(os.path.abspath(__file__))
    app.config.from_file(os.path.join(current_dir, "static", "config.json"), json.load)
    common_object_test(app)


def test_config_from_file_toml():
    tomllib = pytest.importorskip("tomllib", reason="tomllib added in 3.11")
    app = flask.Flask(__name__)
    current_dir = os.path.dirname(os.path.abspath(__file__))
    app.config.from_file(
        os.path.join(current_dir, "static", "config.toml"), tomllib.load, text=False
    )
    common_object_test(app)


def test_from_prefixed_env(monkeypatch):
    monkeypatch.setenv("FLASK_STRING", "value")
    monkeypatch.setenv("FLASK_BOOL", "true")
    monkeypatch.setenv("FLASK_INT", "1")
    monkeypatch.setenv("FLASK_FLOAT", "1.2")
    monkeypatch.setenv("FLASK_LIST", "[1, 2]")
    monkeypatch.setenv("FLASK_DICT", '{"k": "v"}')
    monkeypatch.setenv("NOT_FLASK_OTHER", "other")

    app = flask.Flask(__name__)
    app.config.from_prefixed_env()

    assert app.config["STRING"] == "value"
// ... (191 more lines)

Subdomains

Dependencies

  • flask
  • json
  • os
  • pytest

Frequently Asked Questions

What does test_config.py do?
test_config.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_config.py?
test_config.py defines 18 function(s): common_object_test, test_config_from_class, test_config_from_envvar, test_config_from_envvar_missing, test_config_from_file_json, test_config_from_file_toml, test_config_from_mapping, test_config_from_object, test_config_from_pyfile, test_config_missing, and 8 more.
What does test_config.py depend on?
test_config.py imports 4 module(s): flask, json, os, pytest.
Where is test_config.py in the architecture?
test_config.py is located at tests/test_config.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