How do I code lots of simple tests
Ian Bicking
ianb at colorstudy.com
Wed Oct 22 15:20:13 EDT 2003
More information about the Python-list mailing list
Wed Oct 22 15:20:13 EDT 2003
- Previous message (by thread): Unittest - How do I code lots of simple tests
- Next message (by thread): Unittest - How do I code lots of simple tests
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tuesday, October 21, 2003, at 11:48 PM, Jeremy Fincher wrote: > Ian Bicking <ianb at colorstudy.com> wrote in message > news:<mailman.319.1066774834.2192.python-list at python.org>... >> (And it uses double-underscore variables, like it's just >> *trying* to piss me off! Double-underscore variables are so arrogant >> and patronizing. > > Don't look at it like that. Double-underscore variables are for > averting namespace problems, not for protection. Unittest uses them > not to protect itself, but to keep from stomping all over your > namespace when you subclass it. In that way, it's very much built > with subclassing in mind. I never have problems with namespaces like that. If you really do have significant likelihood of a namespace clash then you shouldn't be using inheritance -- some of those instance variables should be shifted into a separate object. I generally assume that a subclass is made with the superclass in mind, and that subclasses will be respectful of the requirements of the superclass. If I'm not sure I trust the subclassing programmer, then I'll add lots of asserts. The asserts cover the *actual* requirements. Double-underscore says "I won't even tell you the requirements, because I don't believe you can be trusted with them. Instead I'll hide it all from you." You can still unmangle the names -- which I frequently do -- but it's annoying. This is open source -- sure, things may change in some later version, and if I go playing around with undocumented interfaces then I won't be surprised if some future version breaks my code. I'm okay with that, and it should be my choice to make fragile code if I want. -- Ian Bicking | ianb at colorstudy.com | http://blog.ianbicking.org
- Previous message (by thread): Unittest - How do I code lots of simple tests
- Next message (by thread): Unittest - How do I code lots of simple tests
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list