some py3 fixes for RFC2616Policy

This commit is contained in:
Konstantin Lopuhin 2016-01-15 13:13:10 +03:00
parent ea0471e33a
commit 87849780bc
2 changed files with 4 additions and 3 deletions

View File

@ -41,7 +41,8 @@ class RFC2616Policy(object):
def __init__(self, settings):
self.always_store = settings.getbool('HTTPCACHE_ALWAYS_STORE')
self.ignore_schemes = settings.getlist('HTTPCACHE_IGNORE_SCHEMES')
self.ignore_response_cache_controls = settings.getlist('HTTPCACHE_IGNORE_RESPONSE_CACHE_CONTROLS')
self.ignore_response_cache_controls = map(
to_bytes, settings.getlist('HTTPCACHE_IGNORE_RESPONSE_CACHE_CONTROLS'))
self._cc_parsed = WeakKeyDictionary()
def _parse_cachecontrol(self, r):

View File

@ -291,7 +291,7 @@ class RFC2616PolicyTest(DefaultStorageTest):
self.assertEqualResponse(res2, res3)
# request with no-cache directive must not return cached response
# but it allows new response to be stored
res0b = res0.replace(body='foo')
res0b = res0.replace(body=b'foo')
res4 = self._process_requestresponse(mw, req2, res0b)
self.assertEqualResponse(res4, res0b)
assert 'cached' not in res4.flags
@ -435,7 +435,7 @@ class RFC2616PolicyTest(DefaultStorageTest):
assert 'cached' not in res1.flags
# Same request but as cached response is stale a new response must
# be returned
res0b = res0a.replace(body='bar')
res0b = res0a.replace(body=b'bar')
res2 = self._process_requestresponse(mw, req0, res0b)
self.assertEqualResponse(res2, res0b)
assert 'cached' not in res2.flags