Skip to main content
 首页 » 编程设计

python之使用 python 3.3 运行 pytest

2024年11月01日11lautakyan007

我在 Mac 上同时安装了 Python 2.7 和 3.3。我试图让 Pytest 在 Python 3.3 下运行我的测试。

当我运行 python3 –m py.test 时,它会停止,寻找 3.3 路径下的库。

当我运行 pip install –U pytest 时,它会安装到 2.7 路径。

我看过有关 Virtualenv 的文章,但我还没有准备好去那里。

还有别的办法吗?

请您参考如下方法:

看看 tox项目。它可以帮助您在不同的 Python 版本和解释器下测试您的代码。

示例 tox.ini 配置为您的案例:

[tox] 
envlist = py27,py33 
[testenv] 
deps = pytest 
commands = py.test 

这不是 Elixir ,但它肯定有助于自动化您繁琐的测试事件。