2011-10-25 35 views
3

我目前正在通过专业Plone 4开发,同时使用4.1.2的统一安装程序。我不确定是否在本书的显式构建过程中使用安装程序会导致问题,但我在安装示例时遇到了很多麻烦。现在,我正在为正在创建的策略包运行测试。使用plone.app.testing导入错误

在包的setup.py,我有:

extras_require={ 
    'test': ['plone.app.testing',] 
}, 

develop.cfg

[buildout] 
parts += 
    test 

[test] 
recipe = zc.recipe.testrunner 
defaults = ['--auto-color', '--auto-progress'] 

最后,testing.py进口:

from plone.app.testing import (
    PloneSandboxLayer, 
    applyProfile, 
    PLONE_FIXTURE, 
    IntegrationTesting, 
) 

使用开发配置运行构建之后,测试运行器按预期方式安装到bin/test。但是,试图运行测试该软件包使我有以下几点:

$ bin/test -s ctcc.policy 
bin/test:239: DeprecationWarning: zope.testing.testrunner is deprecated in favour of zope.testrunner. 
/opt/plone41/buildout-cache/eggs/zope.testing-3.9.6-py2.6.egg/zope/testing/testrunner/formatter.py:28: DeprecationWarning: zope.testing.exceptions is deprecated in favour of zope.testrunner.exceptions 
    from zope.testing.exceptions import DocTestFailureException 
Test-module import failures: 

Module: ctcc.policy.tests 

Traceback (most recent call last): 
    File "/opt/plone41/zeocluster/src/ctcc.policy/ctcc/policy/tests.py", line 2, in <module> 
    from ctcc.policy.testing import CTCC_POLICY_INTEGRATION_TESTING 
    File "/opt/plone41/zeocluster/src/ctcc.policy/ctcc/policy/testing.py", line 1, in <module> 
    from plone.app.testing import (
ImportError: No module named testing 

什么我需要做的是能够使用plone.app.testing?

如果问题是由于它使用了zope.testing.testrunner而不是zope.testrunner,那么它是在哪里指定的?我无法在任何buildout配置中找到对它的引用。

谢谢。

回答

7

你必须在测试中指定节与extra_requires关键的鸡蛋,像这样:

[test] 
recipe = zc.recipe.testrunner 
eggs = 
    my.package [test] 
defaults = ['--auto-color', '--auto-progress'] 

更多信息:

+1

在我的防守,我没有阅读你链接到的文档,我只是没有深入到它提到的文档中:http://pypi.python.org/pypi/plone.testing#adding-a-test-buildout-to-your-包 –

+0

谢谢,这个帮了很多。 –