Skip to content

Commit a47f2d6

Browse files
committed
Add test for custom caching backends
1 parent 32715b5 commit a47f2d6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/test_basic_app.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
# -*- coding: utf-8 -*-
22
from flask import Flask
3+
from werkzeug.contrib.cache import SimpleCache
34
from flask_caching import Cache
45

56

7+
class CustomSimpleCache(SimpleCache):
8+
pass
9+
10+
11+
def newsimple(app, config, args, kwargs):
12+
return CustomSimpleCache(*args, **kwargs)
13+
14+
615
def test_dict_config(app):
716
cache = Cache(config={'CACHE_TYPE': 'simple'})
817
cache.init_app(app)
@@ -55,3 +64,12 @@ def test_init_app_multi_apps(app):
5564

5665
with app2.app_context():
5766
assert cache.cache.key_prefix == 'bar'
67+
68+
69+
def test_app_custom_cache_backend(app):
70+
cache = Cache()
71+
app.config['CACHE_TYPE'] = 'test_basic_app.newsimple'
72+
cache.init_app(app)
73+
74+
with app.app_context():
75+
assert isinstance(cache.cache, CustomSimpleCache)

0 commit comments

Comments
 (0)