summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2011-11-20 10:17:12 +0000
committerAymeric Augustin <aymeric.augustin@m4x.org>2011-11-20 10:17:12 +0000
commit7075e932565d3a28d53ff014f0e33ce46df53496 (patch)
tree95a80216a19ade061b3f15629390ac6e5f625902 /tests
parentf6ee168919dd3638dc1a78e8cad068663cf3051e (diff)
Made the database cache backend, which bypasses the ORM, compatible with time zone support.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17119 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/cache/models.py4
-rw-r--r--tests/regressiontests/cache/tests.py6
2 files changed, 7 insertions, 3 deletions
diff --git a/tests/regressiontests/cache/models.py b/tests/regressiontests/cache/models.py
index 31b988a86d..2cd648b780 100644
--- a/tests/regressiontests/cache/models.py
+++ b/tests/regressiontests/cache/models.py
@@ -1,11 +1,11 @@
-from datetime import datetime
+from django.utils import timezone
from django.db import models
def expensive_calculation():
expensive_calculation.num_runs += 1
- return datetime.now()
+ return timezone.now()
class Poll(models.Model):
question = models.CharField(max_length=200)
diff --git a/tests/regressiontests/cache/tests.py b/tests/regressiontests/cache/tests.py
index 5f9676beb6..8cb7c2e4ec 100644
--- a/tests/regressiontests/cache/tests.py
+++ b/tests/regressiontests/cache/tests.py
@@ -746,7 +746,7 @@ def custom_key_func(key, key_prefix, version):
return 'CUSTOM-' + '-'.join([key_prefix, str(version), key])
-class DBCacheTests(unittest.TestCase, BaseCacheTests):
+class DBCacheTests(BaseCacheTests, TestCase):
backend_name = 'django.core.cache.backends.db.DatabaseCache'
def setUp(self):
@@ -763,6 +763,7 @@ class DBCacheTests(unittest.TestCase, BaseCacheTests):
from django.db import connection
cursor = connection.cursor()
cursor.execute('DROP TABLE %s' % connection.ops.quote_name(self._table_name))
+ connection.commit()
def test_cull(self):
self.perform_cull_test(50, 29)
@@ -776,6 +777,9 @@ class DBCacheTests(unittest.TestCase, BaseCacheTests):
self.perform_cull_test(50, 18)
+DBCacheWithTimeZoneTests = override_settings(USE_TZ=True)(DBCacheTests)
+
+
class DBCacheRouter(object):
"""A router that puts the cache table on the 'other' database."""