|
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | from __future__ import absolute_import, division, print_function |
| 3 | +from unittest import TestCase |
3 | 4 |
|
4 | 5 | import pymemcache.client |
5 | 6 | import flask |
6 | 7 | import flask.ext.pymemcache |
7 | 8 |
|
8 | 9 |
|
9 | | -def test_simple(): |
10 | | - pymc = pymemcache.client.Client(('localhost', 11211)) |
11 | | - memcache = flask.ext.pymemcache.FlaskPyMemcache() |
12 | | - app = flask.Flask(__name__) |
13 | | - app.config['PYMEMCACHE'] = { |
14 | | - 'server': ('localhost', 11211), |
15 | | - 'key_prefix': b'px'} |
16 | | - memcache.init_app(app) |
| 10 | +class TestFlaskPyMemcache(TestCase): |
| 11 | + def test_simple(self): |
| 12 | + pymc = pymemcache.client.Client(('localhost', 11211)) |
| 13 | + memcache = flask.ext.pymemcache.FlaskPyMemcache() |
| 14 | + app = flask.Flask(__name__) |
| 15 | + app.config['PYMEMCACHE'] = { |
| 16 | + 'server': ('localhost', 11211), |
| 17 | + 'key_prefix': b'px'} |
| 18 | + memcache.init_app(app) |
17 | 19 |
|
18 | | - with app.app_context(): |
19 | | - memcache.client.set(b'foo', b'bar') |
20 | | - assert memcache.client.get(b'foo') == b'bar' |
| 20 | + with app.app_context(): |
| 21 | + memcache.client.set(b'foo', b'bar') |
| 22 | + assert memcache.client.get(b'foo') == b'bar' |
21 | 23 |
|
22 | | - assert pymc.get(b'pxfoo') == b'bar' |
| 24 | + assert pymc.get(b'pxfoo') == b'bar' |
0 commit comments