diff --git a/tests/timezones/models.py b/tests/timezones/models.py index f7747d5937..a6e276f2f4 100644 --- a/tests/timezones/models.py +++ b/tests/timezones/models.py @@ -25,3 +25,7 @@ class Timestamp(models.Model): class AllDayEvent(models.Model): day = models.DateField() + + +class DailyEvent(models.Model): + time = models.TimeField() diff --git a/tests/timezones/tests.py b/tests/timezones/tests.py index 861636ddf1..58c69bf769 100644 --- a/tests/timezones/tests.py +++ b/tests/timezones/tests.py @@ -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)