gpt4 book ai didi

testing - 使用 plone.app.testing 导入错误

转载 作者:行者123 更新时间:2023-11-28 19:55:52 24 4
gpt4 key购买 nike

我目前正在使用 4.1.2 的统一安装程序进行 Professional Plone 4 Development。我不确定在书中的显式构建过程中使用安装程序是否会导致问题,但我在将示例与安装的实际情况联系起来时遇到了很多麻烦。现在,我在为正在创建的策略包运行测试时遇到问题。

在包的 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,
)

在使用 develop 配置运行 buildout 后,测试运行器按预期安装到 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.testrunner 上使用 zope.testing.testrunner 引起的,那么具体在哪里指定?我在任何构建配置中都找不到对它的引用。

谢谢。

最佳答案

您必须使用 extra_requires 键在测试节中指定您的 egg,如下所示:

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

更多信息:

关于testing - 使用 plone.app.testing 导入错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7885867/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com