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

David Cournapeau cournape at gmail.com
Tue Oct 6 12:18:30 CEST 2015


On Tue, Oct 6, 2015 at 10:54 AM, Donald Stufft <donald at stufft.io> wrote:

> On October 6, 2015 at 3:21:04 AM, Glyph Lefkowitz (glyph at twistedmatrix.com)
> wrote:
> > > 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 .
>
> I dislike putting tests inside the package.
>
> The supposed benefit is that anyone can run the tests at anytime, but I
> don't
> find that actually true because it means (as someone else pointed out)
> that you
> either have to depend on all your test dependencies or that there is
> already an
> additional step to install them. If you're going to have to locate and
> install
> the test dependencies, then you might as well fetch the tarball with tests
> as
> well.
>
> Someone suggested setuptools test_requires, but that only functions when
> you
> have a setup.py available and you execute ``setup.py test``. It does not
> help
> you at all once the package is installed and the sdist is gone.
>
> I also don't think people actually run the tests when they are installed
> in any
> significant number, at least I've never once in my life done it or even
> had a
> desire to do it.
>

The significant number is not so relevant if you buy the argument that it
is useful to downstream packagers: it may be a few users, but those are
crucial.

I also forgot to mention that  the ability to test something without
building is crucial when you want to distribute binaries.

David


> Some projects have test suites which are significantly large too. The PyCA
> cryptography project for instance, has to ship it's vectors as an
> additional
> package to reduce the size of the final build product.
>
> -----------------
> Donald Stufft
> PGP: 0x6E3CBCE93372DCFA // 7C6B 7C5D 5E2B 6356 A926 F04F 6E3C BCE9 3372
> DCFA
>
>
> _______________________________________________
> Distutils-SIG maillist  -  Distutils-SIG at python.org
> https://mail.python.org/mailman/listinfo/distutils-sig
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20151006/4492199a/attachment.html>


More information about the Distutils-SIG mailing list