#17275 closed Cleanup/optimization (fixed)
Fix RuntimeWarning in the Django test suite
Reported by: | Paul McMillan | Owned by: | nobody |
---|---|---|---|
Component: | Testing framework | Version: | dev |
Severity: | Release blocker | Keywords: | |
Cc: | slacy@… | Triage Stage: | Ready for checkin |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Django's test suite currently raises a RuntimeWarning
in several places. The localflavor
re-arrangement in r16680 may have borked the warning supression for ca/ca_provinces
and id/id_choices
(or it may have happened earlier in the history, I didn't hunt the exact changeset down).
Additionally, the DateTimeField
raises RuntimeWarning
in several tests after the timezone refactor.
In any case, we know we changed those things, so warning ourselves in our own test suite is silly.
Attachments (1)
Change History (15)
comment:1 by , 13 years ago
Severity: | Normal → Release blocker |
---|
comment:2 by , 13 years ago
comment:3 by , 13 years ago
Owner: | changed from | to
---|
comment:4 by , 13 years ago
The localflavor-related warnings actually started appearing after r17009. E.g. imports of django/contrib/localflavor/id/id_choices.py
(the one raising the warning at the module level) in django/contrib/localflavor/id/forms.py
were moved from class level to module level and so the RuntimeWarning
is triggered when contrib.localflavor.id
is simply imported.
I don't think they can be filtered out in this condition. Maybe we can move these imports back to the class level?
Something similar happens with the ca
localflavor.
comment:5 by , 13 years ago
The warnings related to time-zone support are caused by initial_data fixtures that contain naive datetimes.
The solution is two-fold:
- rename initial_data fixtures and load them specifically in the tests that need them;
- change the tests of the initial_data feature itself to use a fixture that doesn't contain datetimes.
comment:8 by , 13 years ago
Owner: | changed from | to
---|
DateTimeField
no longer sends warnings in the test suite.
comment:9 by , 13 years ago
Easy pickings: | unset |
---|---|
Needs tests: | unset |
The localflavor warnings appeared after r17009:
- https://code.djangoproject.com/changeset/17009#file4
- https://code.djangoproject.com/changeset/17009#file17
Attached patch removes the warnings. What do you think?
by , 13 years ago
Attachment: | 17275.diff added |
---|
comment:10 by , 13 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:12 by , 13 years ago
I'm just switching our codebase to 1.4c2 and have run into this issue in the test suites.
To make sure it wasn't something I was doing, I did the following:
$ django-admin.py startproject blank $ cd blank/blank $ <edit settings.py and set DB ENGINE to 'django.db.backends.sqlite3' $ django-admin.py test Creating test database for alias 'default'... ..../home/slacy/src/oswebsite/wsve/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py:808: RuntimeWarning: DateTimeField received a naive datetime (2007-05-30 13:20:10) while time zone support is active. RuntimeWarning) ...../home/slacy/src/oswebsite/wsve/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py:808: RuntimeWarning: DateTimeField received a naive datetime (2006-12-17 07:03:31) while time zone support is active. RuntimeWarning) ........................../home/slacy/src/oswebsite/wsve/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py:808: RuntimeWarning: DateTimeField received a naive datetime (2012-01-13 00:14:00) while time zone support is active. RuntimeWarning) ...............................................................................................................................................................................................................................................................................................................s....................................................................... ---------------------------------------------------------------------- Ran 410 tests in 10.039s OK (skipped=1) Destroying test database for alias 'default'...
comment:13 by , 13 years ago
Cc: | added |
---|
I'll deal with the warnings related to time-zone support. They were introduced at r17117.