[TIP] including tests in packages, or not

C. Titus Brown ctb at msu.edu
Sun Sep 13 18:55:55 PDT 2009

Hi all,

I'm whipping together a quick little tagging Web site for an initiative,
and I thought I'd try putting all of my tests in the package itself --


nose still finds them there, of course, and with the new import
mechanisms I don't have to do any of my usual path manipulations to get
the tests to import the right package ahead of other things in my
sys.path -- I can just do

    from .. import foo.py

to get at 'tagnabbit.foo', for example.

Another advantage is that I can install the tests with tagnabbit, which
is nice.

So, so far I'm happy with this layout.  What am I missing?


My normal layout is to put the tests at the same level as the package in
my dev dir, e.g.

    tagnabbit/  -- package

where I usually munge sys.path to get the import to load my dev version
of tagnabbit as opposed to whatever might be installed.

C. Titus Brown, ctb at msu.edu

More information about the testing-in-python mailing list