[Distutils] Where should I put my tests in my package?

Fred Drake fdrake at acm.org
Wed Nov 17 18:01:47 CET 2010


On Wed, Nov 17, 2010 at 10:14 AM, W. Matthew Wilson <matt at tplus1.com> wrote:
> 1.  I would like to put lots of tests/ folders next to the code they
> test, rather than at the top level of the project.  How do I make sure
> the tests folders don't get installed?

I'm sure there's a way to prevent installation in this case, but I
don't know what it is.

> 2.  Should I worry about not installing tests?  Should I install them?

Unless you're targeting storage-constrained platform, why shouldn't
you install them?

> 3.  Is there any pattern I should follow for organizing my tests
> within my project?

There's a lot of variations here.  Some people prefer your original
arrangement, and others prefer embedding the tests within each package
as you're describing for your new arrangement.  (The later is widely
used in the Zope community.)

Another approach, good if you want to avoid installation of the tests,
is to use a mirror hierarchy for your tests:

pitz/
   pitz/
       cmdline/
       webapp/
           handlers/
               __init__.py
               statichandler.py

       entity/

   tests/
       commandline/
           test_cmdline.py
       webapp/
           test_webapp.py
           handlers/
               test_handlers.py
               test_statichandler.py
       entity/
           test_entity.py

I favor the Zopish approach these days.


  -Fred

--
Fred L. Drake, Jr.    <fdrake at acm.org>
"A storm broke loose in my mind."  --Albert Einstein


More information about the Distutils-SIG mailing list