

@requires_tz_support
def test_query_filter_with_naive_datetime(self):
    dt = datetime.datetime(2011, 9, 1, 12, 20, 30, tzinfo=EAT)
    Event.objects.create(dt=dt)
    dt = dt.replace(tzinfo=None)
    with warnings.catch_warnings(record=True) as recorded:
        warnings.simplefilter('always')
        self.assertEqual(Event.objects.filter(dt__exact=dt).count(), 1)
        self.assertEqual(Event.objects.filter(dt__lte=dt).count(), 1)
        self.assertEqual(Event.objects.filter(dt__gt=dt).count(), 0)
        self.assertEqual(len(recorded), 3)
        for warning in recorded:
            msg = str(warning.message)
            self.assertTrue(msg.startswith('DateTimeField Event.dt received a naive datetime'))

dataset/ETHPy150Open django/django/tests/timezones/tests.py NewDatabaseTests.test_query_filter_with_naive_datetime/original