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

Robert Collins robertc at robertcollins.net
Wed Oct 7 01:32:43 CEST 2015


On 6 October 2015 at 20:07, Thomas Güttler <guettliml at thomas-guettler.de> wrote:
> Hi,
>
> Where should I put tests when packaging python modules?
>
> I want a "cowpath", an "obvious way"
>
> Dear experts, please decide:
>
> inside the module like this answer:
>
>  http://stackoverflow.com/questions/5341006/where-should-i-put-tests-when-packaging-python-modules
>
> XOR
>
> outside the module like this:
>
>  https://github.com/pypa/sampleproject/tree/master/tests
>
> I think there is no need to hurry. Let's wait one week,
> and then check which one is preferred.

My preference is to have the tests clearly namespaced to the project.
That can be done one of three ways:

./projectpackage/[zero-or-more-dirs-deep]/tests
./projectname_tests/
./tests with a runner configuration to add appropriate metadata

The namespacing lets me gather up test output from multiple projects
and not have it confused (nor have to artificially separate out what
tests ran in what test process).

This is mainly useful when taking a big-data mindset to your tests, so
not relevant so much to 'heres my 1k loc project, enjoy world'
scenarios.

-Rob

-- 
Robert Collins <rbtcollins at hp.com>
Distinguished Technologist
HP Converged Cloud


More information about the Distutils-SIG mailing list