Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python - Running tox + nosetests on a Python 3.2 testenv

I've been trying to implement a single-source testing system that allows automated testing across multiple Python versions using tox + nosetests.

Problem is, I can't get it working whenever I test against Python 3.2. Everything works fine if I exclude Python 3.2.

Here's my tox.ini:

[tox]
envlist = py25,py26,py27,py32,pypy,jython

[testenv]
commands =
    nosetests []
deps =
    nose
    mock

[testenv:py32]
commands =
    nosetests []

and my ~/.noserc:

[nosetests]
verbosity=2
with-doctest=1

I've set the use_2to3 flag to True in my setup.py, but this error keeps showing up: NameError: global name 'basestring' is not defined. It seems that I'm missing some setting that should make 2to3 work, but I don't know what it is.

Additionally, I've tried replacing nosetests [] with python setup.py test in the testenv:py32 setting. Unfortunately, not only the same error keeps showing up, it also introduces another error: Error in atexit._run_exitfuncs: TypeError: 'NoneType' object is not callable.

Any pointers?

EDIT: added the code in setup.py, in case it's useful:

# handle python 3
if sys.version_info >= (3,):
    use_2to3 = True
else:
    use_2to3 = False

and somewhere in setup(): use_2to3 = use_2to3

like image 636
bow Avatar asked Mar 13 '12 12:03

bow


1 Answers

You might use something like this in the [testenv] section:

changedir = {envtmpdir}
commands = nosetests package  # "package" is import name of the package under test

or if you have tests in a separate directory than the package:

changedir = tests  # directory where tests are living
commands = nosetests []

This should prevent nose from picking up the wrong package version.

like image 125
hpk42 Avatar answered Sep 30 '22 10:09

hpk42