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

Antoine Pitrou solipsis at pitrou.net
Tue Oct 6 09:51:01 CEST 2015


On Tue, 6 Oct 2015 09:07:46 +0200
Thomas Güttler <guettliml at thomas-guettler.de> wrote:
> 
> Dear experts, please decide:
> 
> inside the module like this answer:
> 
>  http://stackoverflow.com/questions/5341006/where-should-i-put-tests-when-packaging-python-modules

They should be inside the module. That way, you can check an installed
module is ok by running e.g. "python -m mypackage.tests". Any other
choice makes testing installed modules more cumbersome.

> outside the module like this:
> 
>  https://github.com/pypa/sampleproject/tree/master/tests

There is no actual reason to do that except win a couple kilobytes if
you are distributing your package on floppy disks for consumption on
Z80-based machines with 64KB RAM.

Even Python *itself* puts its test suite inside the standard library,
not outside it (though some Linux distros may strip it away).
Try "python -m test.regrtest" (again, this may fail if your distro
decided to ship the test suite in a separate package).

The PyP"A" should definitely fix its sample project to reflect good
practices.

Regards

Antoine.




More information about the Distutils-SIG mailing list