test_instance_config.py — flask Source File
Architecture documentation for test_instance_config.py, a python file in the flask codebase. 9 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 27c06adb_1aab_74d2_a3c7_31e63b6a6a6f["test_instance_config.py"] bdc6911d_da67_3a1f_90cb_90f5e9f0603e["os"] 27c06adb_1aab_74d2_a3c7_31e63b6a6a6f --> bdc6911d_da67_3a1f_90cb_90f5e9f0603e da94d511_b8b8_a450_f67f_fc28ea9b648a["pytest"] 27c06adb_1aab_74d2_a3c7_31e63b6a6a6f --> da94d511_b8b8_a450_f67f_fc28ea9b648a 8c762fc5_c0b6_0d4d_3889_896d80fbf225["flask"] 27c06adb_1aab_74d2_a3c7_31e63b6a6a6f --> 8c762fc5_c0b6_0d4d_3889_896d80fbf225 e3331161_4263_0077_caab_8eecefc449c8["config_module_app"] 27c06adb_1aab_74d2_a3c7_31e63b6a6a6f --> e3331161_4263_0077_caab_8eecefc449c8 caf83745_9a46_8d4c_df00_1677e222c5bb["config_package_app"] 27c06adb_1aab_74d2_a3c7_31e63b6a6a6f --> caf83745_9a46_8d4c_df00_1677e222c5bb a0f69751_4aac_2122_52d0_7ccf71ba7f77["namespace.package2"] 27c06adb_1aab_74d2_a3c7_31e63b6a6a6f --> a0f69751_4aac_2122_52d0_7ccf71ba7f77 0358bd5b_30d5_181c_1992_61e31351fbde["site_app"] 27c06adb_1aab_74d2_a3c7_31e63b6a6a6f --> 0358bd5b_30d5_181c_1992_61e31351fbde a808523e_e487_ca94_eb75_4b9c7ca228e4["installed_package"] 27c06adb_1aab_74d2_a3c7_31e63b6a6a6f --> a808523e_e487_ca94_eb75_4b9c7ca228e4 411cd4d3_c240_9e1f_01a3_ed29fcc3bbe6["site_package"] 27c06adb_1aab_74d2_a3c7_31e63b6a6a6f --> 411cd4d3_c240_9e1f_01a3_ed29fcc3bbe6 style 27c06adb_1aab_74d2_a3c7_31e63b6a6a6f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import os
import pytest
import flask
def test_explicit_instance_paths(modules_tmp_path):
with pytest.raises(ValueError, match=".*must be absolute"):
flask.Flask(__name__, instance_path="instance")
app = flask.Flask(__name__, instance_path=os.fspath(modules_tmp_path))
assert app.instance_path == os.fspath(modules_tmp_path)
def test_uninstalled_module_paths(modules_tmp_path, purge_module):
(modules_tmp_path / "config_module_app.py").write_text(
"import os\n"
"import flask\n"
"here = os.path.abspath(os.path.dirname(__file__))\n"
"app = flask.Flask(__name__)\n"
)
purge_module("config_module_app")
from config_module_app import app
assert app.instance_path == os.fspath(modules_tmp_path / "instance")
def test_uninstalled_package_paths(modules_tmp_path, purge_module):
app = modules_tmp_path / "config_package_app"
app.mkdir()
(app / "__init__.py").write_text(
"import os\n"
"import flask\n"
"here = os.path.abspath(os.path.dirname(__file__))\n"
"app = flask.Flask(__name__)\n"
)
purge_module("config_package_app")
from config_package_app import app
assert app.instance_path == os.fspath(modules_tmp_path / "instance")
def test_uninstalled_namespace_paths(tmp_path, monkeypatch, purge_module):
def create_namespace(package):
project = tmp_path / f"project-{package}"
monkeypatch.syspath_prepend(os.fspath(project))
ns = project / "namespace" / package
ns.mkdir(parents=True)
(ns / "__init__.py").write_text("import flask\napp = flask.Flask(__name__)\n")
return project
_ = create_namespace("package1")
project2 = create_namespace("package2")
purge_module("namespace.package2")
purge_module("namespace")
from namespace.package2 import app
assert app.instance_path == os.fspath(project2 / "instance")
def test_installed_module_paths(
modules_tmp_path, modules_tmp_path_prefix, purge_module, site_packages
):
(site_packages / "site_app.py").write_text(
"import flask\napp = flask.Flask(__name__)\n"
)
purge_module("site_app")
from site_app import app
assert app.instance_path == os.fspath(
modules_tmp_path / "var" / "site_app-instance"
)
def test_installed_package_paths(
modules_tmp_path, modules_tmp_path_prefix, purge_module, monkeypatch
):
installed_path = modules_tmp_path / "path"
installed_path.mkdir()
monkeypatch.syspath_prepend(installed_path)
app = installed_path / "installed_package"
app.mkdir()
(app / "__init__.py").write_text("import flask\napp = flask.Flask(__name__)\n")
purge_module("installed_package")
from installed_package import app
assert app.instance_path == os.fspath(
modules_tmp_path / "var" / "installed_package-instance"
)
def test_prefix_package_paths(
modules_tmp_path, modules_tmp_path_prefix, purge_module, site_packages
):
app = site_packages / "site_package"
app.mkdir()
(app / "__init__.py").write_text("import flask\napp = flask.Flask(__name__)\n")
purge_module("site_package")
import site_package
assert site_package.app.instance_path == os.fspath(
modules_tmp_path / "var" / "site_package-instance"
)
Domain
Subdomains
Functions
Dependencies
- config_module_app
- config_package_app
- flask
- installed_package
- namespace.package2
- os
- pytest
- site_app
- site_package
Source
Frequently Asked Questions
What does test_instance_config.py do?
test_instance_config.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_instance_config.py?
test_instance_config.py defines 7 function(s): test_explicit_instance_paths, test_installed_module_paths, test_installed_package_paths, test_prefix_package_paths, test_uninstalled_module_paths, test_uninstalled_namespace_paths, test_uninstalled_package_paths.
What does test_instance_config.py depend on?
test_instance_config.py imports 9 module(s): config_module_app, config_package_app, flask, installed_package, namespace.package2, os, pytest, site_app, and 1 more.
Where is test_instance_config.py in the architecture?
test_instance_config.py is located at tests/test_instance_config.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