forked from orbit-oss/flask
Leave eggs when finding the instance path
This commit is contained in:
parent
74f4af59f6
commit
fb1a6730cf
2 changed files with 22 additions and 1 deletions
|
|
@ -568,8 +568,12 @@ class Flask(_PackageBoundObject):
|
||||||
package_path = self.root_path
|
package_path = self.root_path
|
||||||
if hasattr(root_mod, '__path__'):
|
if hasattr(root_mod, '__path__'):
|
||||||
package_path = os.path.dirname(package_path)
|
package_path = os.path.dirname(package_path)
|
||||||
site_parent, site_folder = os.path.split(package_path)
|
|
||||||
|
|
||||||
|
# leave the egg wrapper folder or the actual .egg on the filesystem
|
||||||
|
if os.path.basename(package_path).endswith('.egg'):
|
||||||
|
package_path = os.path.dirname(package_path)
|
||||||
|
|
||||||
|
site_parent, site_folder = os.path.split(package_path)
|
||||||
py_prefix = os.path.abspath(sys.prefix)
|
py_prefix = os.path.abspath(sys.prefix)
|
||||||
if package_path.startswith(py_prefix):
|
if package_path.startswith(py_prefix):
|
||||||
base_dir = py_prefix
|
base_dir = py_prefix
|
||||||
|
|
|
||||||
|
|
@ -1077,6 +1077,23 @@ class InstanceTestCase(unittest.TestCase):
|
||||||
finally:
|
finally:
|
||||||
sys.modules['myapp'] = None
|
sys.modules['myapp'] = None
|
||||||
|
|
||||||
|
def test_egg_installed_paths(self):
|
||||||
|
import types
|
||||||
|
expected_prefix = os.path.abspath(sys.prefix)
|
||||||
|
package_path = os.path.join(expected_prefix, 'lib', 'python2.5',
|
||||||
|
'site-packages', 'MyApp.egg', 'myapp')
|
||||||
|
mod = types.ModuleType('myapp')
|
||||||
|
mod.__path__ = [package_path]
|
||||||
|
mod.__file__ = os.path.join(package_path, '__init__.py')
|
||||||
|
sys.modules['myapp'] = mod
|
||||||
|
try:
|
||||||
|
mod.app = flask.Flask(mod.__name__)
|
||||||
|
self.assertEqual(mod.app.instance_path,
|
||||||
|
os.path.join(expected_prefix, 'share',
|
||||||
|
'myapp-instance'))
|
||||||
|
finally:
|
||||||
|
sys.modules['myapp'] = None
|
||||||
|
|
||||||
|
|
||||||
class JSONTestCase(unittest.TestCase):
|
class JSONTestCase(unittest.TestCase):
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue