
On Wed, Nov 17, 2010 at 11:26 AM, Marius Gedminas <marius@pov.lt> 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?
3. Is there any pattern I should follow for organizing my tests within my project?
My approach is a bit different from what has been suggested. I create a separate tests directory which mirrors the structure of the packages I want to test, and install them in a (share) data directory. So, in setup.py I have import os, os.path ... data_dir = 'share/pitz/' data_files = \ [(os.path.join(data_dir, root), [os.path.join(root, file_name) for file_name in files]) for root, dirs, files in os.walk('tests')] + other_data_files ... and in MANIFEST.in I have recursive-include tests *.py so the directory structure would look like this: pitz/ src/ pitz/ cmdline/ webapp/ handlers/ __init__.py statichandler.py entity/ tests/ pitz/ cmdline/ webapp/ handlers/ __init__.py test_statichandler.py entity/ setup.py MANIFEST.in I like this approach because it cleanly separates the tests from the actual package code, the tests go into the data directory, rather than with the package itself, and I can easily decide whether to include or not the tests with the distribution. -- Ernesto Posse Applied Formal Methods Group - Software Technology Lab School of Computing Queen's University - Kingston, Ontario, Canada