Unicode support for request_cached decorator and commentable_id
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Tests for the request cache.
|
||||
"""
|
||||
@@ -183,6 +184,28 @@ class TestRequestCache(TestCase):
|
||||
self.assertEqual(result, 4)
|
||||
self.assertEqual(to_be_wrapped.call_count, 4)
|
||||
|
||||
def test_request_cached_mixed_unicode_str_args(self):
|
||||
"""
|
||||
Ensure that request_cached can work with mixed str and Unicode parameters.
|
||||
"""
|
||||
RequestCache.clear_request_cache()
|
||||
|
||||
def dummy_function(arg1, arg2):
|
||||
"""
|
||||
A dummy function that expects an str and unicode arguments.
|
||||
"""
|
||||
assert isinstance(arg1, str), 'First parameter has to be of type `str`'
|
||||
assert isinstance(arg2, unicode), 'Second parameter has to be of type `unicode`'
|
||||
return True
|
||||
|
||||
self.assertTrue(dummy_function('Hello', u'World'), 'Should be callable with ASCII chars')
|
||||
self.assertTrue(dummy_function('H∂llå', u'Wørld'), 'Should be callable with non-ASCII chars')
|
||||
|
||||
wrapped = request_cached(dummy_function)
|
||||
|
||||
self.assertTrue(wrapped('Hello', u'World'), 'Wrapper should handle ASCII only chars')
|
||||
self.assertTrue(wrapped('H∂llå', u'Wørld'), 'Wrapper should handle non-ASCII chars')
|
||||
|
||||
def test_request_cached_with_none_result(self):
|
||||
"""
|
||||
Ensure that calling a decorated function that returns None
|
||||
|
||||
Reference in New Issue
Block a user