mirror of https://github.com/django/django.git
Added test for errors when saving timezone-aware times if not supported.
This commit is contained in:
parent
f35ab74752
commit
6a5ef557f8
|
@ -25,3 +25,7 @@ class Timestamp(models.Model):
|
|||
|
||||
class AllDayEvent(models.Model):
|
||||
day = models.DateField()
|
||||
|
||||
|
||||
class DailyEvent(models.Model):
|
||||
time = models.TimeField()
|
||||
|
|
|
@ -37,7 +37,8 @@ from .forms import (
|
|||
EventSplitForm,
|
||||
)
|
||||
from .models import (
|
||||
AllDayEvent, Event, MaybeEvent, Session, SessionEvent, Timestamp,
|
||||
AllDayEvent, DailyEvent, Event, MaybeEvent, Session, SessionEvent,
|
||||
Timestamp,
|
||||
)
|
||||
|
||||
try:
|
||||
|
@ -270,6 +271,13 @@ class LegacyDatabaseTests(TestCase):
|
|||
class NewDatabaseTests(TestCase):
|
||||
naive_warning = 'DateTimeField Event.dt received a naive datetime'
|
||||
|
||||
@skipIfDBFeature('supports_timezones')
|
||||
def test_aware_time_unsupported(self):
|
||||
t = datetime.time(13, 20, 30, tzinfo=EAT)
|
||||
msg = 'backend does not support timezone-aware times.'
|
||||
with self.assertRaisesMessage(ValueError, msg):
|
||||
DailyEvent.objects.create(time=t)
|
||||
|
||||
@requires_tz_support
|
||||
def test_naive_datetime(self):
|
||||
dt = datetime.datetime(2011, 9, 1, 13, 20, 30)
|
||||
|
|
Loading…
Reference in New Issue