python - 在Python 3.2 testenv上运行tox + nosetests

bow*_*bow 7 python testing automated-tests nose python-3.x

我一直在尝试实现一个单源测试系统,允许使用tox + nosetests跨多个Python版本进行自动测试.

问题是,每当我测试Python 3.2时,我都无法使它工作.如果我排除Python 3.2,一切正常.

这是我的tox.ini:

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

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

[testenv:py32]
commands =
    nosetests []
Run Code Online (Sandbox Code Playgroud)

和我的~/.noserc:

[nosetests]
verbosity=2
with-doctest=1
Run Code Online (Sandbox Code Playgroud)

我在我的setup.py中设置了use_2to3标志True,但是这个错误不断出现:NameError: global name 'basestring' is not defined.似乎我错过了一些应该2to3工作的设置,但我不知道它是什么.

此外,我试图取代nosetests []python setup.py testtestenv:py32设置.不幸的是,不仅相同的错误不断出现,还引入了另一个错误:Error in atexit._run_exitfuncs: TypeError: 'NoneType' object is not callable.

有什么指针吗?

编辑:添加代码setup.py,以防它有用:

# handle python 3
if sys.version_info >= (3,):
    use_2to3 = True
else:
    use_2to3 = False
Run Code Online (Sandbox Code Playgroud)

在某处setup():use_2to3 = use_2to3

hpk*_*k42 1

您可以在本节中使用类似的内容[testenv]

changedir = {envtmpdir}
commands = nosetests package  # "package" is import name of the package under test
Run Code Online (Sandbox Code Playgroud)

或者如果您的测试位于与包不同的目录中:

changedir = tests  # directory where tests are living
commands = nosetests []
Run Code Online (Sandbox Code Playgroud)

这应该可以防止鼻子拾取错误的软件包版本。