Skip to content
Myr

test_instance_config.py

This file

Path

tests/test_instance_config.py

111 lines · 3.3 KiB · Python

Last changed by

Merge branch '2.3.x'David Lordbefore adoption57e926c

History of this file

Take it

The walk stopped after 200 commits: lines older than 93a7f08 point at it.

Merge branch '2.3.x'David Lordbefore adoption57e926c

line 1why, one step back
1import os

pin os and python version in rtd buildDavid Lordbefore adoption93a7f08

lines 2–7why, one step back
2
3import pytest45import flask67

Merge branch '2.3.x'David Lordbefore adoption57e926c

lines 8–9why, one step back
8def test_explicit_instance_paths(modules_tmp_path):
9 with pytest.raises(ValueError, match=".*must be absolute"):

pin os and python version in rtd buildDavid Lordbefore adoption93a7f08

lines 10–11why, one step back
10 flask.Flask(__name__, instance_path="instance")
11

Merge branch '2.3.x'David Lordbefore adoption57e926c

lines 12–13why, one step back
12 app = flask.Flask(__name__, instance_path=os.fspath(modules_tmp_path))
13 assert app.instance_path == os.fspath(modules_tmp_path)

pin os and python version in rtd buildDavid Lordbefore adoption93a7f08

lines 14–15why, one step back
14
15

Merge branch '2.3.x'David Lordbefore adoption57e926c

lines 16–17why, one step back
16def test_uninstalled_module_paths(modules_tmp_path, purge_module):
17 (modules_tmp_path / "config_module_app.py").write_text(

pin os and python version in rtd buildDavid Lordbefore adoption93a7f08

lines 18–26why, one step back
18 "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 app26

Merge branch '2.3.x'David Lordbefore adoption57e926c

line 27why, one step back
27 assert app.instance_path == os.fspath(modules_tmp_path / "instance")

pin os and python version in rtd buildDavid Lordbefore adoption93a7f08

lines 28–29why, one step back
28
29

Merge branch '2.3.x'David Lordbefore adoption57e926c

lines 30–33why, one step back
30def 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(

pin os and python version in rtd buildDavid Lordbefore adoption93a7f08

lines 34–42why, one step back
34 "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 app42

Merge branch '2.3.x'David Lordbefore adoption57e926c

line 43why, one step back
43 assert app.instance_path == os.fspath(modules_tmp_path / "instance")

Merge branch '2.1.x'David Lordbefore adoption7a2d5fb

lines 44–45why, one step back
44
45

Merge branch '2.3.x'David Lordbefore adoption57e926c

line 46why, one step back
46def test_uninstalled_namespace_paths(tmp_path, monkeypatch, purge_module):

Merge branch '2.1.x'David Lordbefore adoption7a2d5fb

line 47why, one step back
47 def create_namespace(package):

Merge branch '2.3.x'David Lordbefore adoption57e926c

lines 48–52why, one step back
48 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.1.x'David Lordbefore adoption7a2d5fb

lines 53–61why, one step back
53 return project
5455 _ = create_namespace("package1")56 project2 = create_namespace("package2")57 purge_module("namespace.package2")58 purge_module("namespace")5960 from namespace.package2 import app61

Merge branch '2.3.x'David Lordbefore adoption57e926c

line 62why, one step back
62 assert app.instance_path == os.fspath(project2 / "instance")

pin os and python version in rtd buildDavid Lordbefore adoption93a7f08

lines 63–65why, one step back
63
6465def test_installed_module_paths(

Merge branch '2.3.x'David Lordbefore adoption57e926c

line 66why, one step back
66 modules_tmp_path, modules_tmp_path_prefix, purge_module, site_packages, limit_loader

pin os and python version in rtd buildDavid Lordbefore adoption93a7f08

line 67why, one step back
67):

Merge branch '2.3.x'David Lordbefore adoption57e926c

line 68why, one step back
68 (site_packages / "site_app.py").write_text(

pin os and python version in rtd buildDavid Lordbefore adoption93a7f08

lines 69–74why, one step back
69 "import flask\napp = flask.Flask(__name__)\n"
70 )71 purge_module("site_app")7273 from site_app import app74

Merge branch '2.3.x'David Lordbefore adoption57e926c

lines 75–77why, one step back
75 assert app.instance_path == os.fspath(
76 modules_tmp_path / "var" / "site_app-instance"77 )

pin os and python version in rtd buildDavid Lordbefore adoption93a7f08

lines 78–80why, one step back
78
7980def test_installed_package_paths(

Merge branch '2.3.x'David Lordbefore adoption57e926c

line 81why, one step back
81 limit_loader, modules_tmp_path, modules_tmp_path_prefix, purge_module, monkeypatch

pin os and python version in rtd buildDavid Lordbefore adoption93a7f08

line 82why, one step back
82):

Merge branch '2.3.x'David Lordbefore adoption57e926c

lines 83–84why, one step back
83 installed_path = modules_tmp_path / "path"
84 installed_path.mkdir()

pin os and python version in rtd buildDavid Lordbefore adoption93a7f08

lines 85–86why, one step back
85 monkeypatch.syspath_prepend(installed_path)
86

Merge branch '2.3.x'David Lordbefore adoption57e926c

lines 87–89why, one step back
87 app = installed_path / "installed_package"
88 app.mkdir()89 (app / "__init__.py").write_text("import flask\napp = flask.Flask(__name__)\n")

pin os and python version in rtd buildDavid Lordbefore adoption93a7f08

lines 90–93why, one step back
90 purge_module("installed_package")
9192 from installed_package import app93

Merge branch '2.3.x'David Lordbefore adoption57e926c

lines 94–95why, one step back
94 assert app.instance_path == os.fspath(
95 modules_tmp_path / "var" / "installed_package-instance"

pin os and python version in rtd buildDavid Lordbefore adoption93a7f08

lines 96–99why, one step back
96 )
979899def test_prefix_package_paths(

Merge branch '2.3.x'David Lordbefore adoption57e926c

line 100why, one step back
100 limit_loader, modules_tmp_path, modules_tmp_path_prefix, purge_module, site_packages

pin os and python version in rtd buildDavid Lordbefore adoption93a7f08

line 101why, one step back
101):

Merge branch '2.3.x'David Lordbefore adoption57e926c

lines 102–104why, one step back
102 app = site_packages / "site_package"
103 app.mkdir()104 (app / "__init__.py").write_text("import flask\napp = flask.Flask(__name__)\n")

pin os and python version in rtd buildDavid Lordbefore adoption93a7f08

lines 105–108why, one step back
105 purge_module("site_package")
106107 import site_package108

Merge branch '2.3.x'David Lordbefore adoption57e926c

lines 109–110why, one step back
109 assert site_package.app.instance_path == os.fspath(
110 modules_tmp_path / "var" / "site_package-instance"

pin os and python version in rtd buildDavid Lordbefore adoption93a7f08

line 111why, one step back
111 )