[TIP] including (or not) tests within your package

Olemis Lang olemis at gmail.com
Wed Jul 28 05:36:19 PDT 2010


On Tue, Jul 27, 2010 at 8:58 AM, Jorge Vargas <jorge.vargas at gmail.com> wrote:
> On Jul 26, 2010 8:19 PM, "Alfredo Deza" <alfredodeza at gmail.com> wrote:
>
>> A few weeks ago in our local Python meeting someone mentioned what a drag
>> was to (most of the time) have to download
>> the source for a package they have just installed to run the tests because
>> the 'test(s)' directory was not included at the time
>> of installation.
>>
>> Some packages include them (like unittest2) and some (most?) don't.
>>
>> What do you guys feel about including the test directory within your
>> package
>> so it is included at the time of installation?
>>
>> I'm gearing towards including them, but wanted to hear your opinion about
>> it.
>
> Speaking from my experience from framework development the general consensus
> is that test-in-packages make things more complicated, as complex packages
> tend to have additional test dependencies

This is the typical situation of using tests_require (testing deps) vs
install_requires (pkg deps) in setuptools . Packages listed using the
former option are not installed after executing `install` command .
This only happens if `test` command is executed and thay are not
already installed ;o)

> and sometimes you need a special
> setup for some of them and tests just bloat the userspace if they are
> distributed together.
>

Part of this solved if modules don't import test code

IMO (even if I don't do it myself :-S ):

  - Distribute tests in sdists
  - Don't install test packages while running `install`
  - Use `tests_require` for test deps
  - Run tests from sdists
  - Provide a separate command (e.g. install_tests)
    in order to install tests separately after
    installing the pkg
  - The previous might imply using absolute imports
    in test code ;o)

That'd be a wish list . Not a few things need to be done in order to
get there due to the fact that part of this is not provided by stdlib
OOTB (CMIIW).

Probably Titus & Michael have considered this & other ideas , since
they were trying to sketch a pkg illustrating the best practices in
this field (SomePackage @ GitHub AFAICR ...)

> My 0.02cents

$0.04
;o)

-- 
Regards,

Olemis.

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:
Soluciones Olimpiadas de Matemática IMO 2007 - Problema 4 -
http://soluciones-olimpiadas.blogspot.com/2010/07/imo-2007-problema-4.html



More information about the testing-in-python mailing list