[Zope3-dev] Unittest pleas

Martijn Faassen faassen@vet.uu.nl
Fri, 20 Dec 2002 20:56:07 +0100


Barry A. Warsaw wrote:
> - please call your test methods "def test<something>" not "def
>   check<something>".  Consistency is good here, and "test" is the
>   unittest default.  When Jeremy and I do ZODB4 grand renaming, we'll
>   fix those tests, but I don't plan to change any existing other Zope3
>   test methods.

Actually the convention should be test_<something> for test methods,
same as for test modules. While test<something> isn't that bad, tests
frequently exercise particular methods and are then named after them.
Not using the _ forces one to uppercase the name of the method you while
test_ does not. For example:

class Foo:
   def myMethod(self):
       pass

class TestFoo:
   def test_myMethod(self):
       pass

   # versus
   def testMyMethod(self):
       pass

In discussions with Guido and Jim, we felt test methods are so special we
can break the normal camel case convention anyway. Test modules have the same
convention as test methods simply as not to confuse people with two separate
conventions. :)

See also:

http://dev.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/DirectoryHierarchyReorganization

Regards,

Martijn