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

W. Matthew Wilson matt at tplus1.com
Wed Nov 17 16:14:13 CET 2010


Right now, I've got a project that started off looking sort of like this:

pitz/
    pitz/
        cmdline/
        webapp/
        entity/

    tests/
        test_cmdline.py
        test_entity.py
        test_webapp.py


In my setup.py file, I have this line

    packages=find_packages(exclude=[''tests']),

so that the tests don't get installed when the code is installed.

This works OK for now, but I'm adding more folders under the original
folders, like this:

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

        entity/

    tests/
        test_cmdline.py
        test_entity.py
        test_webapp.py
        test_handlers.py
        test_statichandler.py

It is getting more difficult to figure out the links between test
files and code files.

I have a few questions:

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?
2.  Should I worry about not installing tests?  Should I install them?
3.  Is there any pattern I should follow for organizing my tests
within my project?

Thanks for the help.

Matt






-- 
W. Matthew Wilson
matt at tplus1.com
http://tplus1.com


More information about the Distutils-SIG mailing list