Skip to content
Myr

Do not break extension tests if tested with installed extensions.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent d4d7570 · Browse files · 3 files+14 added−9 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+14 added−9 removed

  • other:+14 added−9 removed

3 files+14 added−9 removed

modified:flask/testsuite/__init__.py+6 added-8 removed
22 unmodified lines
23from werkzeug.utils import import_string, find_modules242526def add_to_path(path):27 """Adds an entry to sys.path_info if it's not already there."""27 """Adds an entry to sys.path_info if it's not already there. This does28 not append it but moves it to the front so that we can be sure it29 is loaded.30 """31 if not os.path.isdir(path):32 raise RuntimeError('Tried to add nonexisting path')3334 def _samefile(x, y):35 try:36 return os.path.samefile(x, y)37 except (IOError, OSError):38 return False36 for entry in sys.path:37 try:38 if os.path.samefile(path, entry):39 return40 except (OSError, IOError):41 pass42 sys.path.append(path)39 sys.path[:] = [x for x in sys.path if not _samefile(path, x)]40 sys.path.insert(0, path)414243def iter_suites():44 """Yields all testsuites."""
177 unmodified lines
modified:flask/testsuite/ext.py+6 added-1 removed
16 unmodified lines
1718class ExtImportHookTestCase(FlaskTestCase):1920 def setup(self):21 # we clear this out for various reasons. The most important one is22 # that a real flaskext could be in there which would disable our23 # fake package. Secondly we want to make sure that the flaskext24 # import hook does not break on reloading.25 for entry, value in sys.modules.items():26 if (entry.startswith('flask.ext.') or27 entry.startswith('flask_') or24 entry.startswith('flaskext.')) and value is not None:28 entry.startswith('flaskext.') or29 entry == 'flaskext') and value is not None:30 sys.modules.pop(entry, None)31 from flask import ext32 reload(ext)33
78 unmodified lines
modified:run-tests.py+2 added
1#!/usr/bin/env python2import sys, os3sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))4from flask.testsuite import main5main()