[TIP] Using tox with py.test to test on python 2 and python 3

Florian Bauer Florian.Bauer at diasemi.com
Wed Sep 14 02:16:03 PDT 2011


Hi,

I'm trying to set up a tox for a project that is using py.test . 
My goal is to maintain a Python 2.6 source tree for the time being,
but start testing on python 3.2 now.

In the setup.py I'm using distributes use_2to3 flag to automatically
convert the sources to python3 at installation time, like this:

import sys
kw = {}
if sys.version_info >= (3,):
    kw['use_2to3'] = True
setup(
    name = "utilities",
    packages = ["utilities"]
    description = "Various utilities for measurement tasks",
    version = "0.1",
    **kw
    )

I am still not sure on the best way to organize the tests. I tried
adding them as a sub-package of the utilities package, which works,
but I would prefer not to install the test suite. My current tox.ini
looks like this:

[tox]
envlist = py26,py32

[testenv]
changedir={envdir}/lib/site-packages/utilities
deps=
    pytest
sitepackages=True
commands=py.test []

[testenv:py32]
deps=
    sphinx==dev
    pytest
commands=py.test []


Is there support for running 2to3 over a folder in tox? Or should I do
this manually by figuring out the necessary steps and add them to the
commands in testenv:py32 ?


Thanks,
Florian

_______________________________________________________________________________________

Dialog Semiconductor GmbH
Neue Str. 95
D-73230 Kirchheim
Managing Director: Dr. Jalal Bagherli
Chairman of the Supervisory Board: Gregorio Reyes
Commercial register: Amtsgericht Stuttgart: HRB 231181
UST-ID-Nr. DE 811121668


Legal Disclaimer: This e-mail communication (and any attachment/s) is confidential and 
contains proprietary information, some or all of which may be legally privileged. It is 
intended solely for the use of the individual or entity to which it is addressed. Access 
to this email by anyone else is unauthorized. If you are not the intended recipient, any
disclosure, copying, distribution or any action taken or omitted to be taken in reliance
on it, is prohibited and may be unlawful.



More information about the testing-in-python mailing list