[Distutils] Where should I put my tests in my package?
eposse at gmail.com
Wed Nov 17 18:21:31 CET 2010
On Wed, Nov 17, 2010 at 11:26 AM, Marius Gedminas <marius at 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:
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.
Applied Formal Methods Group - Software Technology Lab
School of Computing
Queen's University - Kingston, Ontario, Canada
More information about the Distutils-SIG