Ticket #16134: 16134_fix.diff

File 16134_fix.diff, 1.3 KB (added by RoboHamburger, 13 years ago)

Patch that adds regression test and fix.

  • tests/regressiontests/model_fields/tests.py

     
    2323
    2424
    2525class BasicFieldTests(test.TestCase):
     26    def test_field_can_compare_null(self):
     27        """
     28        Regression test for #16134. Checks to see if a field can be compared with None.
     29        """
     30        field = models.Field()
     31       
     32        self.assertNotEqual(field,None)
     33        self.assertNotEqual(cmp(field,None),0)
     34   
    2635    def test_show_hidden_initial(self):
    2736        """
    2837        Regression test for #12913. Make sure fields with choices respect
  • django/db/models/fields/__init__.py

     
    117117        self.error_messages = messages
    118118
    119119    def __cmp__(self, other):
     120        if not hasattr(other, 'creation_counter'):
     121            return super(self).cmp(self, other)
    120122        # This is needed because bisect does not take a comparison function.
    121123        return cmp(self.creation_counter, other.creation_counter)
    122124
Back to Top