Author: mtredinnick
Date: 2009-03-08 04:59:17 -0500 (Sun, 08 Mar 2009)
New Revision: 9997
Modified:
django/trunk/django/db/models/fields/files.py
django/trunk/tests/regressiontests/file_storage/models.py
Log:
Fixed #9508 -- Added an appropriate FileField.__hash__ implementation.
Required because we declare a custom __eq__ method.
Modified: django/trunk/django/db/models/fields/files.py
===================================================================
--- django/trunk/django/db/models/fields/files.py 2009-03-08 09:58:40 UTC
(rev 9996)
+++ django/trunk/django/db/models/fields/files.py 2009-03-08 09:59:17 UTC
(rev 9997)
@@ -34,6 +34,10 @@
def __ne__(self, other):
return not self.__eq__(other)
+ def __hash__(self):
+ # Required because we defined a custom __eq__.
+ return hash(self.name)
+
# The standard File contains most of the necessary properties, but
# FieldFiles can be instantiated without a name, so that needs to
# be checked for here.
Modified: django/trunk/tests/regressiontests/file_storage/models.py
===================================================================
--- django/trunk/tests/regressiontests/file_storage/models.py 2009-03-08
09:58:40 UTC (rev 9996)
+++ django/trunk/tests/regressiontests/file_storage/models.py 2009-03-08
09:59:17 UTC (rev 9997)
@@ -54,6 +54,11 @@
>>> p.mugshot != p1.mugshot
True
+Bug #9508: Similarly to the previous test, make sure hash() works as expected
+(equal items must hash to the same value).
+>>> hash(p.mugshot) == hash(p2.mugshot)
+True
+
# Bug #8175: correctly delete files that have been removed off the file system.
>>> import os
>>> p2 = Person(name="Fred")
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---