Commit 055c0110 authored by Malcolm Tredinnick's avatar Malcolm Tredinnick
Browse files

[1.0.x] Fixed #9508 -- Added an appropriate FileField.__hash__ implementation.

Required because we declare a custom __eq__ method.

Backport of r9997 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@10000 bcc190cf-cafb-0310-a4f2-bffc1f526a37
parent 244bb7e6
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -32,6 +32,10 @@ class FieldFile(File):
    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.
+5 −0
Original line number Diff line number Diff line
@@ -54,6 +54,11 @@ False
>>> 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")