[TIP] Where to put unit tests? (What to name subdirectory?)

Daryl Spitzer daryl.spitzer at gmail.com
Fri Dec 5 09:57:41 PST 2008

To follow up, I ended up going with:

- all my unit tests in the 'tests' subdirectory
- integration tests in an 'integration' subdirectory in 'tests' (WITH
a __init__.py)

I run all tests by simply running `nosetests`.  I run unit tests only
with `nosetests --exclude=integration`.  I run integration tests only
with `nosetests --where=tests/integration`.


On Wed, Nov 12, 2008 at 1:44 PM, Grig Gheorghiu
<gheorghe_gheorghiu at yahoo.com> wrote:
> --- On Wed, 11/12/08, Daryl Spitzer <daryl.spitzer at gmail.com> wrote:
>> From: Daryl Spitzer <daryl.spitzer at gmail.com>
>> Subject: Re: [TIP] Where to put unit tests? (What to name subdirectory?)
>> To: "Fred Drake" <fdrake at gmail.com>
>> Cc: tip at lists.idyll.org, testing-in-python at lists.idyll.org
>> Date: Wednesday, November 12, 2008, 1:39 PM
>> >> There is no clear distinction between different
>> types of tests (unit
>> >> vs. integration, etc.).
>> >
>> > You're right, there is no clear distinction.
>> Don't confuse readers of
>> > your code by imposing one artificially.
>> I make a distinction, and I don't think it's
>> imposed artificially.  My
>> unit tests use test doubles and run very quickly, and do
>> not require
>> any resources.  Integration tests and system tests may use
>> some test
>> doubles, but run more slowly and are more likely to require
>> resources
>> like network storage or databases.
> Then why not create sub-directories of 'tests' called unit, integration, acceptance, etc. You can have nose or py.test discover those directories too with some configuration-fu.
> Grig

More information about the testing-in-python mailing list