[TIP] coverage.py with Py2 and Py3

Carl Meyer carl at oddbird.net
Wed Apr 13 17:18:16 PDT 2011


Hi Sean,

On 04/13/2011 08:01 PM, Sean Robinson wrote:
>   "Heavy" to me came from the complexity I was seeing in the
> virtualenv docs versus the very small size (less than 2KLOC including
> tests) of my project.  The 3 use cases listed in virtualenv's
> index.txt are: multiple lib versions within one Py version, lib
> version stability, local lib install.  None of these seemed to match
> my need, so some work was going to be required; if virtualenv could
> even help with my goal of one version of one lib (coverage.py) in
> multiple Py versions.
> 
>   But, because you and Skip argued for its usefulness, I took a third
> look at virtualenv.  I think I finally see that I should be able to do
> something like:
> 
> $ python2.4 virtualenv.py py24
> $ python2.5 virtualenv.py py25
> $ python2.6 virtualenv.py py26
> 
> And I would have three ENV into which I could individually install
> coverage.  Is this correct?

Yup.

The reason I prefer this to simply installing coverage into each Python
version's global site-packages is that I work on a variety of projects,
each with their own testing+development requirements, and this allows me
to install exactly what I need for each project into it's virtualenv(s).
So I am more likely to do something like:

$ python2.5 virtualenv.py django-dev-py25
$ python2.6 virtualenv.py django-dev-py26

It's true that if your Python installations are really only used for
development of a single project, virtualenv doesn't buy you much over
just installing the requirements for working on that project directly
into the Python installation.

>   The reason I ask for confirmation?  My actual attempt at multiple ENV:
> 
> $ python2.6 virtualenv.py py26
> $ python3.1 virtualenv.py py31
> File "virtualenv.py", line 17
>     except ImportError, e:
> SyntaxError: invalid syntax
> 
>   I don't see any references to Py3 in the virtualenv docs or source.
> Does it work with Py3?

The latest release of virtualenv (1.6, released a week or so ago) is
Py3-compatible. Previous releases were not.

Carl



More information about the testing-in-python mailing list