Thanks for the insight! Do you write tests to check for constraints that are optional in definitions, for example?
address4 = models.CharField(max_length=45, null=True, blank=True) could be written as address4 = models.CharField(max_length=45) Were is the most reasonable place to test this is correct (not regressing) What about uniqueness, and composite field uniqueness? # unique_together = (("field1", "field2","field3"),) I'm thinking it would make sense to try to create 2 of an object and save them, and check that it fails On Wed, Jun 18, 2008 at 7:59 AM, John <[EMAIL PROTECTED]> wrote: > > Dictionaries compare equal if they contain the same data, regardless > of key order. There is no need to convert to sorted sequences unless > you need to compare the serialized output (such as in doctests). > > I would guess that one of the models has additional fields added to > its __dict__, perhaps through some caching mechanism. Try printing > ``vars(mo)`` and ``vars(saved_mo)``, and then examine the output > manually. If you truly wish to examine two model objects for equality, > you could try the appended code[1] > > However, I would advise that you remove your test entirely. It is > without point, as Django's unit testing already covers the behavior of > ``Model.send()``. Restrict testing to your own code, before you go mad > "sanity checking" the massive pile of third-party code underlying > yours. > > [1] > -------------------------- > assertEqual (type (mo), type (saved_mo)) > > # Retrieve a list of database model field names > attrs = [f.attname for f in mo._meta.fields] > > # Construct lists based on the model attributes, and compare them > mo_attrs = [getattr (mo, a) for a in attrs] > saved_mo_attrs = [getattr (saved_mo, a) for a in attrs] > assertEqual (mo_attrs, saved_mo_attrs) > -------------------------- > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---