尝试在Plone 4.1上运行基于z3c.form.testing的代码并获得此异常
Traceback (most recent call last):
File "/home/xxx/DATA/projects/SVN_xxx_eggs/Products.xxxPatient/Products/xxxPatient/tests/test_views.py", line 13, in <module>
from z3c.form.testing import TestRequest
File "/home/xxx/DATA/projects/xxx_FOLDER/xxx_414/buildout-cache/eggs/z3c.form-2.5.1-py2.6.egg/z3c/form/testing.py", line 23, in <module>
from zope.app.testing import setup
ImportError: No module named testing
z3c.form是否需要特殊支持或使用Plone 4.1进行单元测试?可能需要在setup.py中引用测试模块,但有没有示例如何执行此操作?
答案 0 :(得分:2)
我认为你这里没有版本问题。您的testrunner似乎无法找到整个程序包zope.app.testing
所以您只需要在您的buildout中指定extra_requires
关键字“test”(请查看此处z3c.form's extras_require),如下所示:
[buildout]
eggs +=
z3c.form [test]
test-packages =
z3c.form
[test]
recipe = zc.recipe.testrunner
defaults = ['--auto-color', '--auto-progress']
eggs =
${buildout:eggs}
${buildout:test-packages}