Testing distributions

You can use distil to test distributions. This is primarily intended for trying out potential dependencies and exercises distlib‘s logic for distinguishing between dependencies needed for setup, testing and post-installation:

$ distil test jinja2
Checking requirements for Jinja2 (2.6) ... done.
The following packages will be downloaded, built and tested:
    Jinja2 (2.6)
Downloading Jinja2-2.6.tar.gz to /tmp/tmpkd4eUK
    380KB @  14 KB/s 100 % Done: 00:00:26
Unpacking ... done.
Building Jinja2 (2.6) ...
    Running check ...
    Running build_ext ...
    Running build_py ...
    Build completed.
Testing Jinja2 (2.6) ...
Running test ...
/tmp/tmpkd4eUK/Jinja2-2.6/build/lib.linux-x86_64-2.7/jinja2/loaders.py:214: UserWarning: Module jinja2 was already imported from /tmp/tmpkd4eUK/Jinja2-2.6/build/lib.linux-x86_64-2.7/jinja2/__init__.py, but /usr/lib/python2.7/dist-packages is being added to sys.path
  from pkg_resources import DefaultProvider, ResourceManager, \
test_do (jinja2.testsuite.ext.ExtensionsTestCase) ... ok
test_extend_late (jinja2.testsuite.ext.ExtensionsTestCase) ... ok
... (many tests omitted for brevity)
module (jinja2.environment.Template)
Doctest: jinja2.environment.Template.module ... ok
FileSystemBytecodeCache (jinja2.bccache)
Doctest: jinja2.bccache.FileSystemBytecodeCache ... ok

----------------------------------------------------------------------
Ran 278 tests in 0.967s

OK

Dependencies of the distribution under test are automatically downloaded and built:

$ distil -e e2 test argproc
Checking requirements for argproc (1.4) ... done.
The following packages will be downloaded and built:
    nose (1.2.1) [for argproc]
    ply (3.4) [for argproc]
The following packages will be downloaded, built and tested:
    argproc (1.4)
Proceed? (y/n) y
Downloading nose-1.2.1.tar.gz to /tmp/tmp_REn8s [for argproc]
    390KB @  11 KB/s 100 % Done: 00:00:35
Unpacking ... done.
Downloading ply-3.4.tar.gz to /tmp/tmpzU9dnC [for argproc]
    135KB @  12 KB/s 100 % Done: 00:00:11
Unpacking ... done.
Downloading argproc-1.4.tar.gz to /tmp/tmp5mgBIO
    10KB @  20 KB/s 100 % Done: 00:00:00
Unpacking ... done.
Building nose (1.2.1) ...
    Running check ...
    Running build_ext ...
    Running build_py ...
    Build completed.
Building ply (3.4) ...
    Running check ...
    Running build_ext ...
    Running build_py ...
    Build completed.
Building argproc (1.4) ...
    Running check ...
    Running build_ext ...
    Running build_py ...
    Build completed.
Testing argproc (1.4) ...
Running test ...
argproc.test.test_processor.TestProcessor.test_attribute_reference ... ok
argproc.test.test_processor.TestProcessor.test_bidrectional ... ok
argproc.test.test_processor.TestProcessor.test_comment ... ok
argproc.test.test_processor.TestProcessor.test_dict ... ok
argproc.test.test_processor.TestProcessor.test_false ... ok
argproc.test.test_processor.TestProcessor.test_float ... ok
argproc.test.test_processor.TestProcessor.test_function_call ... ok
argproc.test.test_processor.TestProcessor.test_function_call_with_multiple_arguments ... ok
argproc.test.test_processor.TestProcessor.test_function_with_validator ... ok
argproc.test.test_processor.TestProcessor.test_global_name ... ok
argproc.test.test_processor.TestProcessor.test_int ... ok
argproc.test.test_processor.TestProcessor.test_list ... ok
argproc.test.test_processor.TestProcessor.test_local_name ... ok
argproc.test.test_processor.TestProcessor.test_mandatory ... ok
argproc.test.test_processor.TestProcessor.test_multiple_rules ... ok
argproc.test.test_processor.TestProcessor.test_multiple_tags ... ok
argproc.test.test_processor.TestProcessor.test_negated_tag ... ok
argproc.test.test_processor.TestProcessor.test_none ... ok
argproc.test.test_processor.TestProcessor.test_optional ... ok
argproc.test.test_processor.TestProcessor.test_reverse ... ok
argproc.test.test_processor.TestProcessor.test_simple ... ok
argproc.test.test_processor.TestProcessor.test_slicing ... ok
argproc.test.test_processor.TestProcessor.test_str_double_quoted ... ok
argproc.test.test_processor.TestProcessor.test_str_single_quoted ... ok
argproc.test.test_processor.TestProcessor.test_subscription ... ok
argproc.test.test_processor.TestProcessor.test_tags ... ok
argproc.test.test_processor.TestProcessor.test_true ... ok
argproc.test.test_processor.TestProcessor.test_tuple ... ok
argproc.test.test_processor.TestProcessor.test_tuple_with_one_entry ... ok
argproc.test.test_processor.TestProcessor.test_unidirectional ... ok
argproc.test.test_processor.TestProcessor.test_validator_callable ... ok
argproc.test.test_processor.TestProcessor.test_validator_function_call ... ok
argproc.test.test_processor.TestProcessor.test_validator_list ... ok
argproc.test.test_processor.TestProcessor.test_validator_literal ... ok
argproc.test.test_processor.TestProcessor.test_validator_tuple ... ok

----------------------------------------------------------------------
Ran 35 tests in 0.180s

OK

Note that the dependencies are not installed - they are downloaded and built purely for the purposes of testing, and discarded afterwards.

Command line reference – distil test

Here is the complete help for the distil‘s test command:

$ distil help test
usage: distil test [-h] [--prereleases] [DIST [DIST ...]]

Test a distribution without installing it.

positional arguments:
  DIST           The name of a distribution.

optional arguments:
  -h, --help     show this help message and exit
  --prereleases  Include pre-releases when testing. By default, pre-releases
                 are skipped.