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

Fred Drake fred at fdrake.net
Tue Oct 6 17:26:29 CEST 2015


On Tue, Oct 6, 2015 at 9:51 AM, David Cournapeau <cournape at gmail.com> wrote:
> More precisely, if I install all our supported packages on Linux:
>  - I count ~ 308 packages by making the assumption that one directory in
> site-packages is a package (wrong but decent approximation)
>  - I count as `with tests` a package with at least one directory called test
> in say package
>
> With those assumptions, I count 46 % packages with tests installed. So it is
> not "not very common". Granted, we are biased toward scientific packages
> which to include tests in the package, but we also package popular
> web/etc... packages.

For what it's worth, the Zope community has long been including tests
inside packages (regardless of whether that's right or wrong).  How
the dependencies issue has been addressed has varied over time and
depending on the authors of each package; sometimes tests_require is
used, other times there's a [test] extra (as setuptools is universally
accepted in the Zope community), and other times the test dependencies
are just made package dependencies.

Since zc.buildout is widely used in the Zope community, getting the
right dependencies for the right processes has never been a
significant issue.

(And yes, most Zope packages use a src/ directory.  Not to isolate the
tests and the implementation, but to isolate the code from other files
that may be present in the package.)


  -Fred

-- 
Fred L. Drake, Jr.    <fred at fdrake.net>
"A storm broke loose in my mind."  --Albert Einstein


More information about the Distutils-SIG mailing list