|
|
|
@ -182,16 +182,16 @@ class TestConfig(object):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestInstance(object): |
|
|
|
|
def test_explicit_instance_paths(self, apps_tmpdir): |
|
|
|
|
def test_explicit_instance_paths(self, modules_tmpdir): |
|
|
|
|
with pytest.raises(ValueError) as excinfo: |
|
|
|
|
flask.Flask(__name__, instance_path='instance') |
|
|
|
|
assert 'must be absolute' in str(excinfo.value) |
|
|
|
|
|
|
|
|
|
app = flask.Flask(__name__, instance_path=str(apps_tmpdir)) |
|
|
|
|
assert app.instance_path == str(apps_tmpdir) |
|
|
|
|
app = flask.Flask(__name__, instance_path=str(modules_tmpdir)) |
|
|
|
|
assert app.instance_path == str(modules_tmpdir) |
|
|
|
|
|
|
|
|
|
def test_main_module_paths(self, apps_tmpdir, purge_module): |
|
|
|
|
app = apps_tmpdir.join('main_app.py') |
|
|
|
|
def test_main_module_paths(self, modules_tmpdir, purge_module): |
|
|
|
|
app = modules_tmpdir.join('main_app.py') |
|
|
|
|
app.write('import flask\n\napp = flask.Flask("__main__")') |
|
|
|
|
purge_module('main_app') |
|
|
|
|
|
|
|
|
@ -199,8 +199,8 @@ class TestInstance(object):
|
|
|
|
|
here = os.path.abspath(os.getcwd()) |
|
|
|
|
assert app.instance_path == os.path.join(here, 'instance') |
|
|
|
|
|
|
|
|
|
def test_uninstalled_module_paths(self, apps_tmpdir, purge_module): |
|
|
|
|
app = apps_tmpdir.join('config_module_app.py').write( |
|
|
|
|
def test_uninstalled_module_paths(self, modules_tmpdir, purge_module): |
|
|
|
|
app = modules_tmpdir.join('config_module_app.py').write( |
|
|
|
|
'import os\n' |
|
|
|
|
'import flask\n' |
|
|
|
|
'here = os.path.abspath(os.path.dirname(__file__))\n' |
|
|
|
@ -209,10 +209,10 @@ class TestInstance(object):
|
|
|
|
|
purge_module('config_module_app') |
|
|
|
|
|
|
|
|
|
from config_module_app import app |
|
|
|
|
assert app.instance_path == str(apps_tmpdir.join('instance')) |
|
|
|
|
assert app.instance_path == str(modules_tmpdir.join('instance')) |
|
|
|
|
|
|
|
|
|
def test_uninstalled_package_paths(self, apps_tmpdir, purge_module): |
|
|
|
|
app = apps_tmpdir.mkdir('config_package_app') |
|
|
|
|
def test_uninstalled_package_paths(self, modules_tmpdir, purge_module): |
|
|
|
|
app = modules_tmpdir.mkdir('config_package_app') |
|
|
|
|
init = app.join('__init__.py') |
|
|
|
|
init.write( |
|
|
|
|
'import os\n' |
|
|
|
@ -223,9 +223,9 @@ class TestInstance(object):
|
|
|
|
|
purge_module('config_package_app') |
|
|
|
|
|
|
|
|
|
from config_package_app import app |
|
|
|
|
assert app.instance_path == str(apps_tmpdir.join('instance')) |
|
|
|
|
assert app.instance_path == str(modules_tmpdir.join('instance')) |
|
|
|
|
|
|
|
|
|
def test_installed_module_paths(self, apps_tmpdir, apps_tmpdir_prefix, |
|
|
|
|
def test_installed_module_paths(self, modules_tmpdir, modules_tmpdir_prefix, |
|
|
|
|
purge_module, site_packages, limit_loader): |
|
|
|
|
site_packages.join('site_app.py').write( |
|
|
|
|
'import flask\n' |
|
|
|
@ -235,12 +235,12 @@ class TestInstance(object):
|
|
|
|
|
|
|
|
|
|
from site_app import app |
|
|
|
|
assert app.instance_path == \ |
|
|
|
|
apps_tmpdir.join('var').join('site_app-instance') |
|
|
|
|
modules_tmpdir.join('var').join('site_app-instance') |
|
|
|
|
|
|
|
|
|
def test_installed_package_paths(self, limit_loader, apps_tmpdir, |
|
|
|
|
apps_tmpdir_prefix, purge_module, |
|
|
|
|
def test_installed_package_paths(self, limit_loader, modules_tmpdir, |
|
|
|
|
modules_tmpdir_prefix, purge_module, |
|
|
|
|
monkeypatch): |
|
|
|
|
installed_path = apps_tmpdir.mkdir('path') |
|
|
|
|
installed_path = modules_tmpdir.mkdir('path') |
|
|
|
|
monkeypatch.syspath_prepend(installed_path) |
|
|
|
|
|
|
|
|
|
app = installed_path.mkdir('installed_package') |
|
|
|
@ -250,10 +250,10 @@ class TestInstance(object):
|
|
|
|
|
|
|
|
|
|
from installed_package import app |
|
|
|
|
assert app.instance_path == \ |
|
|
|
|
apps_tmpdir.join('var').join('installed_package-instance') |
|
|
|
|
modules_tmpdir.join('var').join('installed_package-instance') |
|
|
|
|
|
|
|
|
|
def test_prefix_package_paths(self, limit_loader, apps_tmpdir, |
|
|
|
|
apps_tmpdir_prefix, purge_module, |
|
|
|
|
def test_prefix_package_paths(self, limit_loader, modules_tmpdir, |
|
|
|
|
modules_tmpdir_prefix, purge_module, |
|
|
|
|
site_packages): |
|
|
|
|
app = site_packages.mkdir('site_package') |
|
|
|
|
init = app.join('__init__.py') |
|
|
|
@ -262,18 +262,18 @@ class TestInstance(object):
|
|
|
|
|
|
|
|
|
|
import site_package |
|
|
|
|
assert site_package.app.instance_path == \ |
|
|
|
|
apps_tmpdir.join('var').join('site_package-instance') |
|
|
|
|
modules_tmpdir.join('var').join('site_package-instance') |
|
|
|
|
|
|
|
|
|
def test_egg_installed_paths(self, install_egg, apps_tmpdir, |
|
|
|
|
apps_tmpdir_prefix): |
|
|
|
|
apps_tmpdir.mkdir('site_egg').join('__init__.py').write( |
|
|
|
|
def test_egg_installed_paths(self, install_egg, modules_tmpdir, |
|
|
|
|
modules_tmpdir_prefix): |
|
|
|
|
modules_tmpdir.mkdir('site_egg').join('__init__.py').write( |
|
|
|
|
'import flask\n\napp = flask.Flask(__name__)' |
|
|
|
|
) |
|
|
|
|
install_egg('site_egg') |
|
|
|
|
try: |
|
|
|
|
import site_egg |
|
|
|
|
assert site_egg.app.instance_path == \ |
|
|
|
|
str(apps_tmpdir.join('var/').join('site_egg-instance')) |
|
|
|
|
str(modules_tmpdir.join('var/').join('site_egg-instance')) |
|
|
|
|
finally: |
|
|
|
|
if 'site_egg' in sys.modules: |
|
|
|
|
del sys.modules['site_egg'] |
|
|
|
|