summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/timezones/tests.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/timezones/tests.py b/tests/timezones/tests.py
index 8c1d533165..39158badc1 100644
--- a/tests/timezones/tests.py
+++ b/tests/timezones/tests.py
@@ -10,6 +10,7 @@ from xml.dom.minidom import parseString
from django.contrib.auth.models import User
from django.core import serializers
from django.core.urlresolvers import reverse
+from django.db import connection
from django.db.models import Max, Min
from django.http import HttpRequest
from django.template import (
@@ -265,6 +266,13 @@ class LegacyDatabaseTests(TestCase):
[event],
transform=lambda d: d)
+ def test_cursor_execute_returns_naive_datetime(self):
+ dt = datetime.datetime(2011, 9, 1, 13, 20, 30)
+ Event.objects.create(dt=dt)
+ with connection.cursor() as cursor:
+ cursor.execute('SELECT dt FROM timezones_event WHERE dt = %s', [dt])
+ self.assertEqual(cursor.fetchall()[0][0], dt)
+
def test_filter_date_field_with_aware_datetime(self):
# Regression test for #17742
day = datetime.date(2011, 9, 1)
@@ -556,6 +564,23 @@ class NewDatabaseTests(TestCase):
[event],
transform=lambda d: d)
+ @skipUnlessDBFeature('supports_timezones')
+ def test_cursor_execute_returns_aware_datetime(self):
+ dt = datetime.datetime(2011, 9, 1, 13, 20, 30, tzinfo=EAT)
+ Event.objects.create(dt=dt)
+ with connection.cursor() as cursor:
+ cursor.execute('SELECT dt FROM timezones_event WHERE dt = %s', [dt])
+ self.assertEqual(cursor.fetchall()[0][0], dt)
+
+ @skipIfDBFeature('supports_timezones')
+ def test_cursor_execute_returns_naive_datetime(self):
+ dt = datetime.datetime(2011, 9, 1, 13, 20, 30, tzinfo=EAT)
+ utc_naive_dt = timezone.make_naive(dt, timezone.utc)
+ Event.objects.create(dt=dt)
+ with connection.cursor() as cursor:
+ cursor.execute('SELECT dt FROM timezones_event WHERE dt = %s', [dt])
+ self.assertEqual(cursor.fetchall()[0][0], utc_naive_dt)
+
@requires_tz_support
def test_filter_date_field_with_aware_datetime(self):
# Regression test for #17742