【发布时间】: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']
【问题讨论】: