我是否需要在Plone部署中运行psycopg2测试?

时间:2014-05-23 06:50:44

标签: testing plone psycopg2

当我运行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 / test source

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

然而我仍然在我的'developng-eggs'目录中出现了postgres蛋,这看起来很奇怪(应该在我的〜/ .buildout / eggs?)...而且我不确定bpython,mock,nose应该包含在我的bin / test源文件中运行的etc测试......我猜这些是因为它们包含在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']

2 个答案:

答案 0 :(得分:2)

我认为您必须只运行您的产品的测试。其他人已经在其他环境中运行依赖测试。出于同样的原因:您是否正在运行整个Plone测试用例来测试您的产品?它没用恕我直言。

答案 1 :(得分:1)

您可能需要设置要运行的分发,可能不需要设置要使用的蛋。有关详细信息,请参阅https://pypi.python.org/pypi/plone.testing#installation-and-usage,但示例代码段就足够了:

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