#13171 closed (fixed)
field_subclassing test failing, needs to use get_prep_lookup
Reported by: | Gabriel Hurley | Owned by: | Gabriel Hurley |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Keywords: | get_prep_lookup, get_db_prep_lookup | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I ran the full unit test suite this morning (Windows, SQLite3), and found that the field_subclassing tests were failing because the expected error for an invalid lookup_type
wasn't being raised.
It turns out that the test had not been updated to reflect get_prep_lookup()
being factored out of get_db_prep_lookup()
.
This patch corrects that, and raises a TypeError instead of a FieldError, since the docs say "Your method must be prepared to handle all of these lookup_type values and should raise [...] a TypeError if your field does not support that type of lookup."
Patch is attached, and the test now passes.
Attachments (1)
Change History (10)
by , 15 years ago
Attachment: | field_subclassing_tests_patch.diff added |
---|
comment:1 by , 15 years ago
I am confused. I cannot get this test to fail on current trunk (Windows or Ubuntu, both sqlite), and it is passing on the buildbots (http://buildbot.djangoproject.com/waterfall)...?
follow-up: 4 comment:2 by , 15 years ago
Very strange... let me see if I can track down anything more specific.
comment:3 by , 15 years ago
So, as noted on #13172, the test failure was due to a version-specific bug in Python 2.6.1 and upgrading to version 2.6.5 made the test start passing again. Sorry for that.
However, since the docs now recommend doing db-agnostic checks like validating lookup_type
in get_prep_lookup()
and that a TypeError
should be raised, the patch is still technically valid. It's just not very important.
For docs reference, see here:
http://docs.djangoproject.com/en/dev/howto/custom-model-fields/#django.db.models.get_prep_lookup
We might as well eat our own dogfood and comply with the recommendation in the docs, right?
comment:4 by , 15 years ago
Replying to gabrielhurley:
Very strange... let me see if I can track down anything more specific.
Just for the record, this error shows up with the stock python on Snow Leopard which is indeed 2.6.1.
comment:5 by , 15 years ago
Ha! Good to know. Glad I'm not crazy :-)
Sadly that's all the more reason to apply the patch... even if its a Python problem at its core there are still gonna be a number of people out there running 2.6.1 if it's the default version included in SL.
comment:6 by , 15 years ago
Triage Stage: | Unreviewed → Ready for checkin |
---|
Looks like the test case is wrong anyway in this particular case. If fixing the test case also corrects an obscure test case, I say RFC.
comment:7 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Patches broken test for field_subclassing