Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion flask_cache/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ def __init__(self, app=None, with_jinja2_ext=True, config=None):
self.with_jinja2_ext = with_jinja2_ext
self.config = config

self.app = app
if app is not None:
self.init_app(app, config)

Expand Down Expand Up @@ -185,6 +184,7 @@ def _set_cache(self, app, config):
app.extensions.setdefault('cache', {})
app.extensions['cache'][self] = cache_obj(
app, config, cache_args, cache_options)
self.app = app

@property
def cache(self):
Expand Down
5 changes: 5 additions & 0 deletions test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,11 @@ def test_20_jinja2ext_cache(self):
assert self.cache.get(k) == somevar
assert output == somevar

def test_21_init_app_sets_app_attribute(self):
cache = Cache()
cache.init_app(self.app)
assert cache.app == self.app


if 'TRAVIS' in os.environ:
try:
Expand Down