[Django] #23893: naive dateime warning running tests with MySQL

10 views
Skip to first unread message

Django

unread,
Nov 21, 2014, 3:02:17 PM11/21/14
to django-...@googlegroups.com
#23893: naive dateime warning running tests with MySQL
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: nobody
Type: Bug | Status: new
Component: Database | Version: master
layer (models, ORM) | Keywords:
Severity: Normal | Has patch: 0
Triage Stage: Accepted | Needs tests: 0
Needs documentation: 0 | Easy pickings: 0
Patch needs improvement: 0 |
UI/UX: 0 |
-------------------------------------+-------------------------------------
{{{
test_datetime_output_field (custom_lookups.tests.DateTimeLookupTests) ...
/django/django/db/models/fields/__init__.py:1407: RuntimeWarning:
DateTimeField (unbound)
received a naive datetime (2000-01-01 00:00:00) while time zone support
is active.
RuntimeWarning)
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23893>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 14, 2014, 2:22:18 AM12/14/14
to django-...@googlegroups.com
#23893: naive dateime warning running tests with MySQL
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: mhall1
Type: Bug | Status: assigned
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by mhall1):

* owner: nobody => mhall1
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/23893#comment:1>

Django

unread,
Dec 14, 2014, 3:55:49 AM12/14/14
to django-...@googlegroups.com
#23893: naive dateime warning running tests with MySQL
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: mhall1
Type: Bug | Status: assigned
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by mhall1):

* cc: mhall1 (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/23893#comment:2>

Django

unread,
Dec 14, 2014, 3:56:49 AM12/14/14
to django-...@googlegroups.com
#23893: naive dateime warning running tests with MySQL
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: mhall1
Type: Bug | Status: assigned
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by mhall1):

Unable to reproduce on python 2.7 using MySQLdb connector or python 3.4
using mysqlclient connector. @timgraham, do you have any more information
about the environment this occurred under?

--
Ticket URL: <https://code.djangoproject.com/ticket/23893#comment:3>

Django

unread,
Dec 15, 2014, 1:04:37 PM12/15/14
to django-...@googlegroups.com
#23893: naive dateime warning running tests with MySQL
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: mhall1
Type: Bug | Status: assigned
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by timgraham):

I can reproduce with both of those configurations using `python -Wall
runtests.py --settings=test_mysql custom_lookups`

--
Ticket URL: <https://code.djangoproject.com/ticket/23893#comment:4>

Django

unread,
Dec 15, 2014, 9:59:13 PM12/15/14
to django-...@googlegroups.com
#23893: naive dateime warning running tests with MySQL
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: mhall1
Type: Bug | Status: assigned
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by mhall1):

Thanks. I can reproduce it now. I was missing the -Wall flag.

--
Ticket URL: <https://code.djangoproject.com/ticket/23893#comment:5>

Django

unread,
Dec 15, 2014, 10:47:39 PM12/15/14
to django-...@googlegroups.com
#23893: naive dateime warning running tests with MySQL
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: mhall1
Type: Bug | Status: assigned
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by mhall1):

It looks like the fix for #23714 (line 1402 in
django/db/models/fields/__init__.py) is catching an AttributeError and
mistakenly raising the warning, when the error text is "'DateTimeField'
object has no attribute 'model'" (rather than it being error from pytz).
I'm not so familiar with the codebase yet, but I'll keep looking into it.

--
Ticket URL: <https://code.djangoproject.com/ticket/23893#comment:6>

Django

unread,
Dec 16, 2014, 2:28:03 AM12/16/14
to django-...@googlegroups.com
#23893: naive dateime warning running tests with MySQL
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: mhall1
Type: Bug | Status: assigned
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by mhall1):

​I have a patch available here:
https://github.com/mhall1/django/tree/ticket_23893

Tests passing on python2.7 and python3.4 with mysql backend.

Not sure if its overkill to have a regression test testing a unit test?

--
Ticket URL: <https://code.djangoproject.com/ticket/23893#comment:7>

Django

unread,
Dec 16, 2014, 2:28:43 AM12/16/14
to django-...@googlegroups.com
#23893: naive dateime warning running tests with MySQL
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: mhall1
Type: Bug | Status: assigned
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0

Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by mhall1):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/23893#comment:8>

Django

unread,
Dec 16, 2014, 5:02:51 AM12/16/14
to django-...@googlegroups.com
#23893: naive dateime warning running tests with MySQL
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: mhall1
Type: Bug | Status: assigned
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Ready for
Keywords: | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by berkerpeksag):

* stage: Accepted => Ready for checkin


Comment:

[https://github.com/django/django/pull/3737 PR #3737] LGTM.

--
Ticket URL: <https://code.djangoproject.com/ticket/23893#comment:9>

Django

unread,
Dec 16, 2014, 7:22:59 AM12/16/14
to django-...@googlegroups.com
#23893: naive dateime warning running tests with MySQL
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: mhall1
Type: Bug | Status: closed

Component: Database layer | Version: master
(models, ORM) | Resolution: fixed

Severity: Normal | Triage Stage: Ready for
Keywords: | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Michael Hall <mhall1@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"4fada6f1c9930e589aebe8bdfb5795f69d253c07"]:
{{{
#!CommitTicketReference repository=""
revision="4fada6f1c9930e589aebe8bdfb5795f69d253c07"
Fixed #23893: Added tzinfo to constant datetime in unit test

Added tzinfo to y2k constant (01/01/2000) in
custom_lookups.tests.DateTimeLookupTests.test_datetime_output_field
to fix warning message regarding naive datetimes.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23893#comment:10>

Django

unread,
Dec 16, 2014, 7:23:00 AM12/16/14
to django-...@googlegroups.com
#23893: naive dateime warning running tests with MySQL
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: mhall1
Type: Bug | Status: closed
Component: Database layer | Version: master
(models, ORM) | Resolution: fixed
Severity: Normal | Triage Stage: Ready for
Keywords: | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Aymeric Augustin <aymeric.augustin@…>):

In [changeset:"2cb9d984cf7a0965ca6b1322ab836d56278f8749"]:
{{{
#!CommitTicketReference repository=""
revision="2cb9d984cf7a0965ca6b1322ab836d56278f8749"
Merge pull request #3737 from mhall1/ticket_23893

Fixed #23893: Added tzinfo to constant datetime in unit test
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23893#comment:11>

Reply all
Reply to author
Forward
0 new messages