On 9/11/07, Russell Keith-Magee <[EMAIL PROTECTED]> wrote: > > Well... no. assertEquals exists in Python unittests because > assertEquals exists in JUnit, and unittest emulates the JUnit API. > This API is, in turn, based on xUnit, which was derived from SUnit, > the original Smalltalk implementation written by Kent Beck. > > The motivation in Python was to implement an xUnit API, not design a > specifically Pythonic test API.
But they still get used. assert_(variable, msg) is more concise than if not variable: raise AssertionError(msg) Saves us 20 chars. [sure python has language support for assertion and you could as well write: "assert variable, msg", but this can not be done for validation, and above conciseness holds]. Before: if variable1 == variable2: raise ValidationError(msg) after validate_equal(variable1, variable2, msg) 12 few chars to type. Before: try: User.objects.get(username=variable) except User.DoesNotExist: pass else: raise ValidationError(msg) after: validate_exception(User.DoesNotExist, msg, User.objects.get, username=variable) 27 chars saved. Things like validate_[not_]almost_equal, validate_date_within_range, validate_date_before, validate_date_after will have to be implemented by the users, but if we had such a library with dozens of special purpose functions to assist validation, writing form validation would become all the more sweeter. -- Amit Upadhyay Vakow! www.vakow.com +91-9820-295-512 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" 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-developers?hl=en -~----------~----~----~----~------~----~------~--~---
