Browse Source

Init global test_apps explicitly

pull/1165/head
Markus Unterwaditzer 10 years ago
parent
commit
861aa0db1f
  1. 4
      tests/conftest.py
  2. 4
      tests/test_blueprints.py
  3. 28
      tests/test_ext.py
  4. 2
      tests/test_templating.py

4
tests/conftest.py

@ -14,8 +14,8 @@ import pytest
import textwrap
@pytest.fixture(autouse=True)
def setup_path(monkeypatch):
@pytest.fixture
def test_apps(monkeypatch):
monkeypatch.syspath_prepend(
os.path.abspath(os.path.join(
os.path.dirname(__file__), 'test_apps'))

4
tests/test_blueprints.py

@ -140,7 +140,7 @@ def test_blueprint_url_processors():
assert c.get('/de/').data == b'/de/about'
assert c.get('/de/about').data == b'/de/'
def test_templates_and_static():
def test_templates_and_static(test_apps):
from blueprintapp import app
c = app.test_client()
@ -209,7 +209,7 @@ def test_default_static_cache_timeout():
finally:
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = max_age_default
def test_templates_list():
def test_templates_list(test_apps):
from blueprintapp import app
templates = sorted(app.jinja_env.list_templates())
assert templates == ['admin/index.html', 'frontend/index.html']

28
tests/test_ext.py

@ -52,66 +52,66 @@ def importhook_setup(monkeypatch, request):
request.addfinalizer(teardown)
def test_flaskext_new_simple_import_normal():
def test_flaskext_new_simple_import_normal(test_apps):
from flask.ext.newext_simple import ext_id
assert ext_id == 'newext_simple'
def test_flaskext_new_simple_import_module():
def test_flaskext_new_simple_import_module(test_apps):
from flask.ext import newext_simple
assert newext_simple.ext_id == 'newext_simple'
assert newext_simple.__name__ == 'flask_newext_simple'
def test_flaskext_new_package_import_normal():
def test_flaskext_new_package_import_normal(test_apps):
from flask.ext.newext_package import ext_id
assert ext_id == 'newext_package'
def test_flaskext_new_package_import_module():
def test_flaskext_new_package_import_module(test_apps):
from flask.ext import newext_package
assert newext_package.ext_id == 'newext_package'
assert newext_package.__name__ == 'flask_newext_package'
def test_flaskext_new_package_import_submodule_function():
def test_flaskext_new_package_import_submodule_function(test_apps):
from flask.ext.newext_package.submodule import test_function
assert test_function() == 42
def test_flaskext_new_package_import_submodule():
def test_flaskext_new_package_import_submodule(test_apps):
from flask.ext.newext_package import submodule
assert submodule.__name__ == 'flask_newext_package.submodule'
assert submodule.test_function() == 42
def test_flaskext_old_simple_import_normal():
def test_flaskext_old_simple_import_normal(test_apps):
from flask.ext.oldext_simple import ext_id
assert ext_id == 'oldext_simple'
def test_flaskext_old_simple_import_module():
def test_flaskext_old_simple_import_module(test_apps):
from flask.ext import oldext_simple
assert oldext_simple.ext_id == 'oldext_simple'
assert oldext_simple.__name__ == 'flaskext.oldext_simple'
def test_flaskext_old_package_import_normal():
def test_flaskext_old_package_import_normal(test_apps):
from flask.ext.oldext_package import ext_id
assert ext_id == 'oldext_package'
def test_flaskext_old_package_import_module():
def test_flaskext_old_package_import_module(test_apps):
from flask.ext import oldext_package
assert oldext_package.ext_id == 'oldext_package'
assert oldext_package.__name__ == 'flaskext.oldext_package'
def test_flaskext_old_package_import_submodule():
def test_flaskext_old_package_import_submodule(test_apps):
from flask.ext.oldext_package import submodule
assert submodule.__name__ == 'flaskext.oldext_package.submodule'
assert submodule.test_function() == 42
def test_flaskext_old_package_import_submodule_function():
def test_flaskext_old_package_import_submodule_function(test_apps):
from flask.ext.oldext_package.submodule import test_function
assert test_function() == 42
def test_flaskext_broken_package_no_module_caching():
def test_flaskext_broken_package_no_module_caching(test_apps):
for x in range(2):
with pytest.raises(ImportError):
import flask.ext.broken
def test_no_error_swallowing():
def test_no_error_swallowing(test_apps):
try:
import flask.ext.broken
except ImportError:

2
tests/test_templating.py

@ -306,7 +306,7 @@ def test_templates_auto_reload():
app.config['TEMPLATES_AUTO_RELOAD'] = False
assert not app.jinja_env.auto_reload
def test_template_loader_debugging():
def test_template_loader_debugging(test_apps):
from blueprintapp import app
called = []

Loading…
Cancel
Save