Pet*_*sik 5 python linux debian python-module python-unittest
我尝试在我们的持续集成服务器(Bamboo,在 Debian Jessie 上运行)上使用 XML 输出运行 Python 单元测试,这样我们就可以根据测试结果将构建标记为失败或成功。我目前正在努力解决我无法安装模块的问题xmlrunner。这就是我所做的
sudo apt-get install python-xmlrunner
python3
>>> import xmlrunner
ImportError: No module named 'xmlrunner'
Run Code Online (Sandbox Code Playgroud)
所以我尝试了pip,但它说软件包已经安装
sudo pip install unittest-xml-reporting
Requirement already satisfied (use --upgrade to upgrade): unittest-xml-reporting in /usr/lib/python2.7/dist-packages
Run Code Online (Sandbox Code Playgroud)
顺便说一句,我可以使用 Python 2.7 导入这个模块,这可能意味着这个python-xmlrunner包仅针对 2.7 版本安装。
python3 -m unittest discover project_name我用这样的 main 方法 运行我的测试类unittest.main(testRunner=xmlrunner.XMLTestRunner(output='test-reports'))
您应该使用 安装运行程序pip,我认为该包只是被调用xmlrunner(但也许是 python 2.7)
pip install xmlrunner
Run Code Online (Sandbox Code Playgroud)
更好的是virtualenv内的所有内容。然后你可以传递requirements.txt所有依赖项,并且不需要sudo安装任何东西。然后你可以选择任何你喜欢的Python版本,与你的全局安装隔离。
如果您想检查它是否已安装以及哪个版本,请使用pip freeze
编辑
如果pip install xmlrunner不起作用,请尝试pip install unittest-xml-reporting。谢谢,@scrutari
| 归档时间: |
|
| 查看次数: |
10493 次 |
| 最近记录: |