summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDavid Sanders <shang.xiao.sanders@gmail.com>2023-10-22 18:41:30 +1100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-10-22 19:34:13 +0200
commit4dec7eded9e58d7cefe54ea32137599cd4d1ea69 (patch)
treec935024d41b26d7c5992cc26eaae9a3a5710f48c /tests
parent4979e83d08eab95ebf1cb34d361da5de6d838422 (diff)
[5.0.x] Fixed #34921 -- Fixed crash of warning for unbound naive datetimes.
Backport of b5311ee23219cfb676e2e67667ecba1e5d363aa0 from main
Diffstat (limited to 'tests')
-rw-r--r--tests/timezones/tests.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/timezones/tests.py b/tests/timezones/tests.py
index 433c921cd3..c45f078ef6 100644
--- a/tests/timezones/tests.py
+++ b/tests/timezones/tests.py
@@ -10,6 +10,7 @@ from django.contrib.auth.models import User
from django.core import serializers
from django.db import connection
from django.db.models import F, Max, Min
+from django.db.models.functions import Now
from django.http import HttpRequest
from django.template import (
Context,
@@ -328,6 +329,13 @@ class NewDatabaseTests(TestCase):
self.assertEqual(event.dt, datetime.datetime(2011, 9, 1, tzinfo=EAT))
@requires_tz_support
+ def test_filter_unbound_datetime_with_naive_date(self):
+ dt = datetime.date(2011, 9, 1)
+ msg = "DateTimeField (unbound) received a naive datetime"
+ with self.assertWarnsMessage(RuntimeWarning, msg):
+ Event.objects.annotate(unbound_datetime=Now()).filter(unbound_datetime=dt)
+
+ @requires_tz_support
def test_naive_datetime_with_microsecond(self):
dt = datetime.datetime(2011, 9, 1, 13, 20, 30, 405060)
with self.assertWarnsMessage(RuntimeWarning, self.naive_warning):