[Distutils] Where should I put tests when packaging python modules?

Barry Warsaw barry at python.org
Wed Oct 7 00:16:15 CEST 2015


On Oct 06, 2015, at 05:41 PM, Donald Stufft wrote:

>I’m not sure I understand what you’re advocating here, it sounds like you
>want your tests at something like mycoolproject/tests so that they are
>importable from mycoolproject.tests… but then you talk about symmetry with
>docs/ and tests/ which sounds more like you have top level directories for
>tests/ docs/ and then mycoolproject/.

Ah, sorry for being unclear.

I put tests in myproj/tests so yes they are importable via myproj.tests.  I
also put __init__.py's in my docs/ directory so the directory, but not the
individual .rst doc files are also importable via myproj.docs.  I do this
because of the handy nose2 plugin I cargo cult around that allows me to run
individual tests or doctests with a command line switch.

If I have subpackages, the pattern repeats, so e.g.

myproj/subpkg1/tests -> import myproj.subpkg1.tests
myproj/subpkg2/docs  -> import myproj.subpkg2.docs

Cheers,
-Barry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20151006/fcf5323a/attachment.sig>


More information about the Distutils-SIG mailing list