summaryrefslogtreecommitdiff
path: root/tests/timezones
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2019-07-20 15:38:43 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-12-04 18:22:08 +0100
commitc06492dd87342b5102db44f0d50fa0bb01cbb743 (patch)
tree25c8ba9910ed0851b4efd6bb81fb298adef420a2 /tests/timezones
parentad88524e4db91dc2f148cf40184a81a454ee7aac (diff)
downloaddjango-c06492dd87342b5102db44f0d50fa0bb01cbb743.tar.gz
Fixed #23524 -- Allowed DATABASES['TIME_ZONE'] option on PostgreSQL.
Diffstat (limited to 'tests/timezones')
-rw-r--r--tests/timezones/tests.py32
1 files changed, 9 insertions, 23 deletions
diff --git a/tests/timezones/tests.py b/tests/timezones/tests.py
index a317af5a55..91c8f9f451 100644
--- a/tests/timezones/tests.py
+++ b/tests/timezones/tests.py
@@ -9,8 +9,7 @@ import pytz
from django.contrib.auth.models import User
from django.core import serializers
-from django.core.exceptions import ImproperlyConfigured
-from django.db import connection, connections
+from django.db import connection
from django.db.models import F, Max, Min
from django.http import HttpRequest
from django.template import (
@@ -532,6 +531,14 @@ class NewDatabaseTests(TestCase):
cursor.execute('SELECT dt FROM timezones_event WHERE dt = %s', [utc_naive_dt])
self.assertEqual(cursor.fetchall()[0][0], utc_naive_dt)
+ @skipUnlessDBFeature('supports_timezones')
+ def test_cursor_explicit_time_zone(self):
+ with override_database_connection_timezone('Europe/Paris'):
+ with connection.cursor() as cursor:
+ cursor.execute('SELECT CURRENT_TIMESTAMP')
+ now = cursor.fetchone()[0]
+ self.assertEqual(now.tzinfo.zone, 'Europe/Paris')
+
@requires_tz_support
def test_filter_date_field_with_aware_datetime(self):
# Regression test for #17742
@@ -595,27 +602,6 @@ class ForcedTimeZoneDatabaseTests(TransactionTestCase):
self.assertEqual(event.dt, fake_dt)
-@skipUnlessDBFeature('supports_timezones')
-@override_settings(TIME_ZONE='Africa/Nairobi', USE_TZ=True)
-class UnsupportedTimeZoneDatabaseTests(TestCase):
-
- def test_time_zone_parameter_not_supported_if_database_supports_timezone(self):
- connections.databases['tz'] = connections.databases['default'].copy()
- connections.databases['tz']['TIME_ZONE'] = 'Asia/Bangkok'
- tz_conn = connections['tz']
- try:
- msg = (
- "Connection 'tz' cannot set TIME_ZONE because its engine "
- "handles time zones conversions natively."
- )
- with self.assertRaisesMessage(ImproperlyConfigured, msg):
- tz_conn.cursor()
- finally:
- connections['tz'].close() # in case the test fails
- del connections['tz']
- del connections.databases['tz']
-
-
@override_settings(TIME_ZONE='Africa/Nairobi')
class SerializationTests(SimpleTestCase):