test_instance_config.py
This file
Path
tests/test_instance_config.py
111 lines · 3.2 KiB · Python
Last changed by
Merge branch 'stable'David Lordbefore adoptionb78b5a2
History of this fileTake it
The walk stopped after 200 commits: lines older than 73739a2 point at it.
Merge branch '2.3.x'David Lordbefore adoption57e926c
line 1why, one step back1import osMerge branch '2.2.x'David Lordbefore adoption73739a2
lines 2–7why, one step back23import pytest45import flask67Merge branch '2.3.x'David Lordbefore adoption57e926c
lines 8–9why, one step back8def test_explicit_instance_paths(modules_tmp_path):9 with pytest.raises(ValueError, match=".*must be absolute"):Merge branch '2.2.x'David Lordbefore adoption73739a2
lines 10–11why, one step back10 flask.Flask(__name__, instance_path="instance")11Merge branch '2.3.x'David Lordbefore adoption57e926c
lines 12–13why, one step back12 app = flask.Flask(__name__, instance_path=os.fspath(modules_tmp_path))13 assert app.instance_path == os.fspath(modules_tmp_path)Merge branch '2.2.x'David Lordbefore adoption73739a2
lines 14–15why, one step back1415Merge branch '2.3.x'David Lordbefore adoption57e926c
lines 16–17why, one step back16def test_uninstalled_module_paths(modules_tmp_path, purge_module):17 (modules_tmp_path / "config_module_app.py").write_text(Merge branch '2.2.x'David Lordbefore adoption73739a2
lines 18–26why, one step back18 "import os\n"19 "import flask\n"20 "here = os.path.abspath(os.path.dirname(__file__))\n"21 "app = flask.Flask(__name__)\n"22 )23 purge_module("config_module_app")2425 from config_module_app import app26Merge branch '2.3.x'David Lordbefore adoption57e926c
line 27why, one step back27 assert app.instance_path == os.fspath(modules_tmp_path / "instance")Merge branch '2.2.x'David Lordbefore adoption73739a2
lines 28–29why, one step back2829Merge branch '2.3.x'David Lordbefore adoption57e926c
lines 30–33why, one step back30def test_uninstalled_package_paths(modules_tmp_path, purge_module):31 app = modules_tmp_path / "config_package_app"32 app.mkdir()33 (app / "__init__.py").write_text(Merge branch '2.2.x'David Lordbefore adoption73739a2
lines 34–42why, one step back34 "import os\n"35 "import flask\n"36 "here = os.path.abspath(os.path.dirname(__file__))\n"37 "app = flask.Flask(__name__)\n"38 )39 purge_module("config_package_app")4041 from config_package_app import app42Merge branch '2.3.x'David Lordbefore adoption57e926c
line 43why, one step back43 assert app.instance_path == os.fspath(modules_tmp_path / "instance")Merge branch '2.2.x'David Lordbefore adoption73739a2
lines 44–45why, one step back4445Merge branch '2.3.x'David Lordbefore adoption57e926c
line 46why, one step back46def test_uninstalled_namespace_paths(tmp_path, monkeypatch, purge_module):Merge branch '2.2.x'David Lordbefore adoption73739a2
line 47why, one step back47 def create_namespace(package):Merge branch '2.3.x'David Lordbefore adoption57e926c
lines 48–52why, one step back48 project = tmp_path / f"project-{package}"49 monkeypatch.syspath_prepend(os.fspath(project))50 ns = project / "namespace" / package51 ns.mkdir(parents=True)52 (ns / "__init__.py").write_text("import flask\napp = flask.Flask(__name__)\n")Merge branch '2.2.x'David Lordbefore adoption73739a2
lines 53–61why, one step back53 return project5455 _ = create_namespace("package1")56 project2 = create_namespace("package2")57 purge_module("namespace.package2")58 purge_module("namespace")5960 from namespace.package2 import app61Merge branch '2.3.x'David Lordbefore adoption57e926c
line 62why, one step back62 assert app.instance_path == os.fspath(project2 / "instance")Merge branch '2.2.x'David Lordbefore adoption73739a2
lines 63–65why, one step back636465def test_installed_module_paths(Merge branch 'stable'David Lordbefore adoptionb78b5a2
line 66why, one step back66 modules_tmp_path, modules_tmp_path_prefix, purge_module, site_packagesMerge branch '2.2.x'David Lordbefore adoption73739a2
line 67why, one step back67):Merge branch '2.3.x'David Lordbefore adoption57e926c
line 68why, one step back68 (site_packages / "site_app.py").write_text(Merge branch '2.2.x'David Lordbefore adoption73739a2
lines 69–74why, one step back69 "import flask\napp = flask.Flask(__name__)\n"70 )71 purge_module("site_app")7273 from site_app import app74Merge branch '2.3.x'David Lordbefore adoption57e926c
lines 75–77why, one step back75 assert app.instance_path == os.fspath(76 modules_tmp_path / "var" / "site_app-instance"77 )Merge branch '2.2.x'David Lordbefore adoption73739a2
lines 78–80why, one step back787980def test_installed_package_paths(Merge branch 'stable'David Lordbefore adoptionb78b5a2
line 81why, one step back81 modules_tmp_path, modules_tmp_path_prefix, purge_module, monkeypatchMerge branch '2.2.x'David Lordbefore adoption73739a2
line 82why, one step back82):Merge branch '2.3.x'David Lordbefore adoption57e926c
lines 83–84why, one step back83 installed_path = modules_tmp_path / "path"84 installed_path.mkdir()Merge branch '2.2.x'David Lordbefore adoption73739a2
lines 85–86why, one step back85 monkeypatch.syspath_prepend(installed_path)86Merge branch '2.3.x'David Lordbefore adoption57e926c
lines 87–89why, one step back87 app = installed_path / "installed_package"88 app.mkdir()89 (app / "__init__.py").write_text("import flask\napp = flask.Flask(__name__)\n")Merge branch '2.2.x'David Lordbefore adoption73739a2
lines 90–93why, one step back90 purge_module("installed_package")9192 from installed_package import app93Merge branch '2.3.x'David Lordbefore adoption57e926c
lines 94–95why, one step back94 assert app.instance_path == os.fspath(95 modules_tmp_path / "var" / "installed_package-instance"Merge branch '2.2.x'David Lordbefore adoption73739a2
lines 96–99why, one step back96 )979899def test_prefix_package_paths(Merge branch 'stable'David Lordbefore adoptionb78b5a2
line 100why, one step back100 modules_tmp_path, modules_tmp_path_prefix, purge_module, site_packagesMerge branch '2.2.x'David Lordbefore adoption73739a2
line 101why, one step back101):Merge branch '2.3.x'David Lordbefore adoption57e926c
lines 102–104why, one step back102 app = site_packages / "site_package"103 app.mkdir()104 (app / "__init__.py").write_text("import flask\napp = flask.Flask(__name__)\n")Merge branch '2.2.x'David Lordbefore adoption73739a2
lines 105–108why, one step back105 purge_module("site_package")106107 import site_package108Merge branch '2.3.x'David Lordbefore adoption57e926c
lines 109–110why, one step back109 assert site_package.app.instance_path == os.fspath(110 modules_tmp_path / "var" / "site_package-instance"Merge branch '2.2.x'David Lordbefore adoption73739a2
line 111why, one step back111 )