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

Donald Stufft donald at stufft.io
Tue Oct 6 14:57:12 CEST 2015



On October 6, 2015 at 8:51:30 AM, Antoine Pitrou (solipsis at pitrou.net) wrote:
> On Tue, 6 Oct 2015 15:34:38 +0300
> Ionel Cristian Mărieș wrote:
> >
> > Very few
> > test runners change the current working directory by default [1], so it's
> > better to just get a better project layout. pyca/cryptography
> > is a good example.
>  
> The "src" convention is actually terrible when working with Python
> code, since suddenly you can't experiment easily on a VCS checkout, you
> have to do extra steps and/or write helper scripts for it.

Without doing it, you have very little assurances you’re actually testing
against the installed project and not the project that's sitting in curdir.
This is why pyca/cryptography does it, attempting to run the copy in . won't
do anything but raise an exception since the .so won't be built.

It doesn't really make experimenting in a VCS any harder, since all you need to
do first is run ``pip install -e .`` and it will do a development install and
add the src/ directory to sys.path.

>  
> The fact that few Python projects, including amongst the most popular
> projects, use that convention mean it's really not considered a good
> practice, nor convenient.
>  
>

Of course, the same argument can be made for installing tests, since it's not
very common.

-----------------
Donald Stufft
PGP: 0x6E3CBCE93372DCFA // 7C6B 7C5D 5E2B 6356 A926 F04F 6E3C BCE9 3372 DCFA




More information about the Distutils-SIG mailing list