使用plone.app.testing 出现导入错误

发布于 2024-12-11 21:33:12 字数 1692 浏览 0 评论 0原文

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

在包的 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 造成的,那么具体是在哪里指定的?我在任何构建配置中都找不到对它的引用。

谢谢。

I'm currently working through Professional Plone 4 Development while using the unified installer for 4.1.2. I'm not sure if using the installer over the explicit buildout process in the book is causing issues but I'm having a lot of trouble tying up the examples with the actuality of what is installed. Right now, I'm having an issue with running tests for the policy package I'm creating.

In the package's setup.py, I have:

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

In develop.cfg:

[buildout]
parts +=
    test

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

And finally, testing.py imports:

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

After running buildout using the develop configuration, the test runner is installed as expected to bin/test. But trying to run the tests for that package gives me the following:

$ 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

What do I need to do to be able to use plone.app.testing?

If the issue is due to it using zope.testing.testrunner over zope.testrunner, where exactly is this specified? I can't find a reference to it in any of the buildout configs.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

红焚 2024-12-18 21:33:12

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

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

更多信息:

You have to specify your egg in the test stanza with the extra_requires key, like this:

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

More info:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文