From 4e9ee6d67be37f60a16064cac4fb22a1e8a32939 Mon Sep 17 00:00:00 2001 From: Andrew Arendt Date: Wed, 21 Sep 2016 10:18:16 -0500 Subject: [PATCH] Modified test_instance_config.py (test_main_module_paths) to include instance folders of main modules which flask considers to be 'installed' (a module or package whos path is a sub-path of sys.prefix). --- tests/test_instance_config.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/tests/test_instance_config.py b/tests/test_instance_config.py index 7c2ce6ff..f7b52e03 100644 --- a/tests/test_instance_config.py +++ b/tests/test_instance_config.py @@ -22,22 +22,30 @@ def test_explicit_instance_paths(modules_tmpdir): app = flask.Flask(__name__, instance_path=str(modules_tmpdir)) assert app.instance_path == str(modules_tmpdir) - def test_main_module_paths(modules_tmpdir, purge_module): app = modules_tmpdir.join('main_app.py') - app.write('import flask\n\napp = flask.Flask("__main__")') + app.write( + 'import os\n' + 'import flask\n' + 'app = flask.Flask("__main__")\n' + ) + purge_module('main_app') from main_app import app - here = os.path.abspath(os.getcwd()) - assert app.instance_path == os.path.join(here, 'instance') - + here = os.getcwd() + sys_prefix = os.path.abspath(sys.prefix) + + if here.startswith(sys_prefix): + suffix = 'var/' + app.name + '-instance' + assert app.instance_path == os.path.join(sys_prefix, suffix) + else: + assert app.instance_path == os.path.join(here, 'instance') def test_uninstalled_module_paths(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' 'app = flask.Flask(__name__)\n' ) purge_module('config_module_app') @@ -52,7 +60,6 @@ def test_uninstalled_package_paths(modules_tmpdir, purge_module): init.write( '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')