我有一个正在使用 Pybuilder 构建的项目。我将它克隆到一台新计算机上,当我运行 pyb 时,我的单元测试提示没有名为 xmlrunner 的模块。所以在我执行 pip install xmlrunner 之后,我从 Pybuilder 收到一个构建错误:
'unicode' 对象没有属性 'write'。
如果我从 unittest 搜索路径中删除我的单元测试,构建将成功完成。当我直接运行单元测试时,它们成功完成。所以我认为 XMLRunner 以某种方式失败了。 Pip 安装了 XMLRunner 版本 1.7.7。预先感谢您的帮助。
请您参考如下方法:
我似乎通过执行以下操作来完成此工作:
首先我得到了和你一样的错误:
BUILD FAILED - 'unicode' object has no attribute 'write'
然后我使用 pip 卸载了 xmlrunner 和 unittest-xml-reporting
然后我使用 pyb install_dependencies 重新安装 unittest-xml-reporting
然后当我使用 pyb 时我的单元测试再次开始运行:
There were 1 error(s) and 0 failure(s) in unit tests
这是我当前的 pip list 输出:
pip (7.1.2)
PyBuilder (0.11.1)
setuptools (18.2)
six (1.9.0)
tblib (1.1.0)
unittest-xml-reporting (1.12.0)
wheel (0.24.0)
如果您使用的是 virtualenv,当您在 virtualenv 环境之外安装了 pybuilder 时,您也可能会遇到此错误:
For example, your virtualenv does not have
pybuilderinstalled, but you can still runpybfrom command line. It is thispybuilderthat needs to be removed as well (I am on OSX so it was the default python that came with it)
