繁体   English   中英

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

[英]python - Running tox + nosetests on a Python 3.2 testenv

我一直在尝试实现一个单源测试系统,允许使用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 []

和我的~/.noserc

[nosetests]
verbosity=2
with-doctest=1

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

另外,我尝试用testenv:py32设置中的python setup.py test替换nosetests [] 不幸的是,不仅相同的错误不断出现,它还引入了另一个错误: 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

setup()某个地方: use_2to3 = use_2to3

你可以在[testenv]部分使用这样的东西:

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

或者如果您在与包不同的目录中进行测试:

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

这样可以防止鼻子拿起错误的包装版本。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM