[Zope3-dev] mangled names in tests
Jeremy Hylton
jeremy@alum.mit.edu
Fri, 13 Dec 2002 18:04:00 -0500
I've seen an idiom in several different unittests that I don't
understand. The tests all involve an abstract test class written
against the interface. The abstract class expects to be mixed in with
a class that defines a method to create an instance of the interface
being tested.
Example:
class IFoo(Interface): pass
class TestIFoo: pass
class TestIdempotentFoo: pass
The TestIFoo class expect that TestIdempotentFoo is going to define
some method to return an object implementing IFoo. The idiom is see
is to name that method _TestIFoo__new. This is the mangled form of
__new in TestIFoo.
I propose that we change it to _new() or, in cases where one concrete
test class will mixin several abstract test classes, _testIFoo(). I
think this is much clearer than using a mangled name for something
that isn't a private name at all.
I haven't found a case where _newIFoo() is actually needed, so maybe
that's a YAGNI.
Jeremy