ruamel.yaml有一个回归,与合并的PR一起引入,它改变了代码,对于用宽和窄的Unicode字符编译的Python版本来说,这些代码具有本质上不同的路径。
在预构建/提交测试期间没有找到回归,因为用tox执行的tox从未在具有窄(‘-enable- Unicode =ucs2 2’)Unicode字符的Python上运行。我的2.7.X是用‘--enable- Unicode =ucs4 4’编译的,在Python中,字符串具有动态的Unicode宽度,对于所涉及的代码来说,字符串的宽度为4字节。
我编制了一个2.7.15的狭义版本。如何在一个tox运行中与其他版本(特别是Wide2.7)一起测试窄版本,以便当一个或多个Python版本失败时,不会提交新版本,也不会将包推送到PyPI?
我尝试将目标py27m添加到tox-globinterpreter使用的解释器列表中。
p python2.7m /opt/python/2.7.15m/bin/python然后跑了:
tox -r -e py27m但是这不起作用,因为它使用Python3.6.6来运行测试(这是与之一起执行的interpeter tox )。
在解释器列表中“重载”Python2.6以使用窄2.7:
p python2.6 /opt/python/2.7.15m/bin/python也没起作用。
发布于 2018-07-01 12:13:51
您不能重载解释器列表,这可能与删除对2.6的支持有关(目标Python3.3和使用tox -e py33也不起作用)。但是,在您的py27m中添加特定的tox.ini目标相对容易。
[tox]
toxworkdir = /data2/DATA/tox/ruamel.yaml
envlist = py36,py27,py35,py34,pypy,py27m
[testenv]
commands =
python -c "import sys, sysconfig; print('%s ucs-%s' % (sys.version.replace('\n', ' '), sysconfig.get_config_var('Py_UNICODE_SIZE'), ))"
/bin/bash -c 'pytest _test/test_*.py'
deps =
pytest
[testenv:py27m]
basepython = /opt/python/2.7.15m/bin/pythonpython -c ...命令将在virtualenv环境tox创建的每个环境中安装一些关于python版本的额外反馈,特别是字符宽度,因为默认的tox输出不包括这一点。(为了清晰起见,删除了实际flake8 / codestyle中运行tox.ini的条目)。
连同解释器列表(~/.config/tox/interpreters.lst):
v 1
# Original pattern used:
g /opt/python/?.?/bin/python?.? /opt/python/pypy2/bin/pypy
# Interpreters found:
p python3.6 /opt/python/3.6/bin/python3.6
p python3.4 /opt/python/3.4/bin/python3.4
p python2.7 /opt/python/2.7/bin/python2.7
p python3.5 /opt/python/3.5/bin/python3.5
p python3.7 /opt/python/3.7/bin/python3.7
p pypy /opt/python/pypy2/bin/pypy
e ,现在运行tox -e将导致:
.
.
.
2.7.15 (default, Jun 30 2018, 23:05:50) [GCC 7.3.0] ucs-4
py27m runtests: commands[1] | /bin/bash -c pytest _test/test_*.py
============================= test session starts =============================
platform linux2 -- Python 2.7.15, pytest-3.6.2, py-1.5.4, pluggy-0.6.0
.
.
.
2.7.15 (default, Jul 1 2018, 11:43:51) [GCC 7.3.0] ucs-2
py27m runtests: commands[1] | /bin/bash -c pytest _test/test_*.py
============================= test session starts ==============================
platform linux2 -- Python 2.7.15, pytest-3.6.2, py-1.5.4, pluggy-0.6.0
.
.
.
============= 320 passed, 1 skipped, 7 xfailed in 32.36 seconds ===============
___________________________________ summary ____________________________________
py36: commands succeeded
py27: commands succeeded
py35: commands succeeded
py34: commands succeeded
pypy: commands succeeded
py27m: commands succeeded
congratulations :)这样,使用窄和宽Unicode编译的相同Python版本的代码路径可以一次性测试。
https://stackoverflow.com/questions/51123203
复制相似问题