2011-10-25 37 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

謝謝,這個幫了很多。 –