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

Barry Warsaw barry at python.org
Wed Nov 12 16:45:48 PST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Nov 12, 2008, at 3:45 PM, C. Titus Brown wrote:

> On Wed, Nov 12, 2008 at 12:41:14PM -0800, Daryl Spitzer wrote:
> -> I apologize if this is a FAQ.  I didn't find the answer (or  
> question)
> -> in a quick search.
> ->
> -> Is there a convention for where to put unit tests?
> ->
> -> I favor putting them in a subdirectory named "UnitTests" (following
> -> Michael Foord's example in the Mock sources).  That way I can  
> easily
> -> separate the unit tests from integration tests or system tests.
> ->
> -> But a colleague states that the python stdlib's tests are in a
> -> subdirectory called "tests".  Should I consider that a convention  
> and
> -> stick with it (in spite of its disadvantages)?
>
> That's how I do it; I believe both nose and py.test will discover  
> tests
> under 'tests/', and I've seen it in other packages, too.

I really like putting doctests under a docs/ subdirectory because,  
well that's their primary purpose in life, right? :)

- -Barry

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Darwin)

iQCVAwUBSRt4vHEjvBPtnXfVAQKfQAQAn7INtRB0e1hI+GdwBAvp0Bhn/yWQgxlE
2xW9FU8oGpvgVzEL40/U18Hd0GprZkzgI877d0jNnrHRIIRYxhJzzJHA+8OvGx2n
hPSIC0qE/+yEINEF0dJ68DcrDlGgEE2tdVdoALHAIDouc+vj+rtveT+vkLDM5/zz
JrPEkkqxMkw=
=+yW1
-----END PGP SIGNATURE-----



More information about the testing-in-python mailing list