【问题标题】:Do i need to run psycopg2 tests with my Plone deployment?我需要使用我的 Plone 部署运行 psycopg2 测试吗?
【发布时间】:2014-05-26 09:49:17
【问题描述】:

当我运行 bin/test 来启动我的 custom.package 测试时,我看到 Pscopg2 测试套件出现错误......这些测试是否也应该运行?

$ bin/test
No docs found to test
Test-module import failures:

Module: psycopg2.tests.testconfig

TypeError: Module psycopg2.tests.testconfig does not define any tests


Module: psycopg2.tests.testutils

TypeError: Module psycopg2.tests.testutils does not define any tests

主要错误与没有可用的“psycopg2_test”数据库有关...我检查了我正在运行的 Postgres 实例,但该数据库未在我的 Postgres 中创建...我应该设置它吗?或者当我为我自己的包启动 bin/test 时,我是否应该以某种方式排除这个包的内部测试...?如果是这样,我该怎么做?

Error in test test_async_after_async (psycopg2.tests.test_async.AsyncTests)
Traceback (most recent call last):
  File "/Users/aaronwilliams/.buildout/eggs/unittest2-0.5.1-py2.7.egg/unittest2/case.py", line 333, in run
    self.setUp()
  File "/Users/aaronwilliams/Development/osc/develop-eggs/psycopg2-2.5.1-py2.7-macosx-10.8-x86_64.egg/psycopg2/tests/test_async.py", line 57, in setUp
    self.sync_conn = self.conn
  File "/Users/aaronwilliams/Development/osc/develop-eggs/psycopg2-2.5.1-py2.7-macosx-10.8-x86_64.egg/psycopg2/tests/testutils.py", line 111, in _get_conn
    self._the_conn = self.connect()
  File "/Users/aaronwilliams/Development/osc/develop-eggs/psycopg2-2.5.1-py2.7-macosx-10.8-x86_64.egg/psycopg2/tests/testutils.py", line 105, in connect
    conn = psycopg2.connect(dsn, **kwargs)
  File "/Users/aaronwilliams/Development/osc/develop-eggs/psycopg2-2.5.1-py2.7-macosx-10.8-x86_64.egg/psycopg2/__init__.py", line 164, in connect
    conn = _connect(dsn, connection_factory=connection_factory, async=async)
OperationalError: FATAL:  database "psycopg2_test" does not exist

我的 bin/test 源包含对 psycopg2 的引用,当我运行 buildout 时,egg 出现在我的 develop-eggs 目录中......不确定这是从哪里来的?

bin/测试源

if __name__ == '__main__':
    sys.exit(collective.xmltestreport.runner.run((['--exit-with-status', '--auto-color', '--auto-progress']) + [
        '--test-path', '/Users/aaronwilliams/Development/osc/src/my.package01',
        '--test-path', '/Users/aaronwilliams/Development/osc/src/my.package02',
        '--test-path', '/Users/aaronwilliams/Development/osc/src/my.package03',
        '--test-path', '/Users/aaronwilliams/Development/osc/src/my.package04',
        '--test-path', '/Users/aaronwilliams/Development/osc/src/my.package05',
        '--test-path', '/Users/aaronwilliams/Development/osc/src/my.package06',
        '--test-path', '/Users/aaronwilliams/Development/osc/src/my.package07',
        '--test-path', '/Users/aaronwilliams/Development/osc/src/my.package08',
        '--test-path', '/Users/aaronwilliams/.buildout/eggs/bpython-0.9.7-py2.7.egg',
        '--test-path', '/Users/aaronwilliams/.buildout/eggs/stxnext.pdb-0.2.1-py2.7.egg',
        '--test-path', '/Users/aaronwilliams/.buildout/eggs/doctestpdbhacks-0.1-py2.7.egg',
        '--test-path', '/Users/aaronwilliams/.buildout/eggs/testfixtures-2.3.4-py2.7.egg',
        '--test-path', '/Users/aaronwilliams/.buildout/eggs/manuel-1.5.0-py2.7.egg',
        '--test-path', '/Users/aaronwilliams/.buildout/eggs/nose-1.1.2-py2.7.egg',
        '--test-path', '/Users/aaronwilliams/.buildout/eggs/mock-0.8.0-py2.7.egg',
        '--test-path', '/Users/aaronwilliams/Development/osc/develop-eggs/psycopg2-2.5.1-py2.7-macosx-10.8-x86_64.egg',
        ]))

更新

我在引用的“postgres.cfg”构建文件中找到了一个“[test]”部分...在我将其注释掉并重新运行构建后,bin/test 源不再引用它,并且我没有得到 postgres我运行 bin/test 时的投诉

来自 postgres.cfg

[test]
eggs += ${postgres-psycopg2:egg}

[postgres-psycopg2]
recipe = zc.recipe.egg:custom
egg = psycopg2
environment = postgres-env

但是,我仍然会在我的“develop-eggs”目录中看到 postgres egg,这看起来很奇怪(应该在我的 ~/.buildout/eggs 中?)...我不确定 bpython、mock、nose etc 测试应该包含在我的 bin/test 源文件中运行......我猜这些是因为它们包含在从 buildout.cfg 引用的包含的 .cfg 文件的各种“[test]”部分中,例如

来自 devtools.cfg

# Set up the test runner
[test]
recipe = collective.xmltestreport
eggs = 
    ${eggs:test}
# add some test debugging tools
    bpython
    stxnext.pdb
    doctestpdbhacks
    testfixtures
    manuel
    nose
    mock       
defaults = ['--exit-with-status', '--auto-color', '--auto-progress']

来自 testing.cfg

[test]
recipe = collective.xmltestreport
eggs =  ${eggs:test}
    testfixtures
    manuel
    nose
    mock
defaults = ['--exit-with-status', '--auto-color', '--auto-progress']

【问题讨论】:

    标签: testing plone psycopg2


    【解决方案1】:

    我认为您只能对您的产品进行测试。其他人已经在其他环境上运行了依赖项测试。出于同样的原因:您是否正在运行整个 Plone 测试用例来测试您的产品?恕我直言,这没用。

    【讨论】:

    • 我刚刚运行 bin/test(但不是一段时间),它通常只是运行我的内部产品测试。
    • 我查找了 bin/test 的源代码,它列出了我所有的包以及 psycopg2 包,其中说明了我的 development-eggs 文件夹中的位置...不知道那里是如何/为什么但似乎这就是原因。将其从那里删除,然后重新运行 buildout...
    • 嗯从我的'develop-eggs'目录中删除了鸡蛋“psycopg2-2.5.1-py2.7-macosx-10.8-x86_64.egg”并删除了bin/test文件,重新运行 buildout ... psycopg2 egg 重新出现在我的 develop-eggs 目录中,并且也列在 bin/test 文件中...这是从哪里来的?
    • 在引用的构建文件中找到一个“[test]”部分...在我的问题中添加了一个 update 部分...感谢您的帮助
    【解决方案2】:

    您可能需要设置您想要运行的发行版,也许是通过不设置您想要使用的鸡蛋。有关更多详细信息,请参阅https://pypi.python.org/pypi/plone.testing#installation-and-usage,但示例 sn-p 就足够了:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-02
      • 2019-10-28
      • 2021-07-10
      • 1970-01-01
      • 1970-01-01
      • 2017-05-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多