Hello Djangonauts I'm a noob on both Django and Python, so this question might be easy for the experts out there. I am trying to do test first development during the development of my model code. (I have lots of experience with test first coding in the Java world, no practical experience in the Py world.)
I want to do something like this class ModelTest(TestCase): def test_crud_modelone(self): mo = ModelOne( name="A name" ) mo.save() saved_mo = mo.objects.get(pk=mo.id) assertEqual( vars(mo), vars(saved_mo),"Something not getting saved") That assertEqual line fails. I wrote this def compare(self, obj1, obj2, verbose = False): other = vars(obj2) for d,v in vars(obj1).items(): if isinstance(other.get(d,None),datetime.date): if not other.get(d,None) == v.date(): return False elif not other.get(d,None) == v: return False return True This is probably horrible python, I'm still learning (unlearning Java), but it compares correctly for strings and dates so far that I've tested. My questions are 1) Does anything like this already exist in Python or Django that I should use? 2) If not, would something like this be valuable to polish up and commit to the Django project? Some might be asking why I'm testing if my models can be saved, as most of that functionality is tested when Django is tested. But, I still feel there's a enough that I have to write to warrant a simple sanity test like this. -- If I'm a million miles off base, I don't mind being told so. :) -- Picante Solutions Limited e: [EMAIL PROTECTED] w: 06 757 9488 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---