forked from orbit-oss/flask
Do not break extension tests if tested with installed extensions.
This commit is contained in:
parent
d4d75701bc
commit
56afafae67
3 changed files with 14 additions and 9 deletions
|
|
@ -24,7 +24,10 @@ from werkzeug.utils import import_string, find_modules
|
|||
|
||||
|
||||
def add_to_path(path):
|
||||
"""Adds an entry to sys.path_info if it's not already there."""
|
||||
"""Adds an entry to sys.path_info if it's not already there. This does
|
||||
not append it but moves it to the front so that we can be sure it
|
||||
is loaded.
|
||||
"""
|
||||
if not os.path.isdir(path):
|
||||
raise RuntimeError('Tried to add nonexisting path')
|
||||
|
||||
|
|
@ -33,13 +36,8 @@ def add_to_path(path):
|
|||
return os.path.samefile(x, y)
|
||||
except (IOError, OSError):
|
||||
return False
|
||||
for entry in sys.path:
|
||||
try:
|
||||
if os.path.samefile(path, entry):
|
||||
return
|
||||
except (OSError, IOError):
|
||||
pass
|
||||
sys.path.append(path)
|
||||
sys.path[:] = [x for x in sys.path if not _samefile(path, x)]
|
||||
sys.path.insert(0, path)
|
||||
|
||||
|
||||
def iter_suites():
|
||||
|
|
|
|||
|
|
@ -18,10 +18,15 @@ from flask.testsuite import FlaskTestCase
|
|||
class ExtImportHookTestCase(FlaskTestCase):
|
||||
|
||||
def setup(self):
|
||||
# we clear this out for various reasons. The most important one is
|
||||
# that a real flaskext could be in there which would disable our
|
||||
# fake package. Secondly we want to make sure that the flaskext
|
||||
# import hook does not break on reloading.
|
||||
for entry, value in sys.modules.items():
|
||||
if (entry.startswith('flask.ext.') or
|
||||
entry.startswith('flask_') or
|
||||
entry.startswith('flaskext.')) and value is not None:
|
||||
entry.startswith('flaskext.') or
|
||||
entry == 'flaskext') and value is not None:
|
||||
sys.modules.pop(entry, None)
|
||||
from flask import ext
|
||||
reload(ext)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
import sys, os
|
||||
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
|
||||
from flask.testsuite import main
|
||||
main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue