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

Glyph Lefkowitz glyph at twistedmatrix.com
Tue Oct 6 09:20:36 CEST 2015


> On Oct 6, 2015, at 12:07 AM, 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.
> 
> Regards,
>  Thomas Güttler

Inside the package.

If you put your tests outside your package, then you can't install the tests for two packages simultaneously, because everyone's tests are just in the top-level package "tests".  This tends to infest the whole package, since then tests import things from each other using 'from tests import ...'.  This is recommended by the hitchhiker's guide, and seconded by <http://as.ynchrono.us/2007/12/filesystem-structure-of-python-project_21.html>.

-glyph



More information about the Distutils-SIG mailing list