当同时使用webtest和sqlalchemy时,金字塔无法启动 [英] Pyramid fails to start when webtest and sqlalchemy are used together
问题描述
我正在尝试设置一个金字塔应用程序以同时使用webtest和sqlalchemy. 如果我注释掉SQLAlchemy代码,则webtests可以正常运行.
I am trying to setup a pyramid app to use both webtest and sqlalchemy. If I comment out the SQLAlchemy code, the webtests run without a problem.
[测试日志] https://travis-ci.org/caffeinated-专家/frisbee/builds/91622436
Error
Traceback (most recent call last):
File "frisbee/frisbee/tests/test_cities_page.py", line 18, in setUp
app = main({})
File "frisbee/frisbee/__init__.py", line 15, in main
engine = engine_from_config(settings, 'sqlalchemy.')
File "build/bdist.macosx-10.10-x86_64/egg/sqlalchemy/engine/__init__.py", line 426, in engine_from_config
url = options.pop('url')
KeyError: 'url'
在我的主要 init 文件中,如果我注释掉sqlalchemy引擎设置,则测试运行良好,但我的项目需要sqlalchemy.
In my main init file, if I comment out the sqlalchemy engine setup, then the tests run fine, but I need sqlalchemy for my project.
这是我第一次使用webtest,所以不确定我是否还有其他冲突的配置.
This is is the first time I have used webtest, so not sure if I have some other conflicting config.
[失败代码] https://github.com/caffeinated-expert/frisbee/commit/ea759015de755aca1d7bffca2845b72944572bed
推荐答案
来自 sqlaclhemy文档:
唯一需要的键是(假设使用默认前缀)sqlalchemy.url
The only required key is (assuming the default prefix) sqlalchemy.url
在您的test_cities_page.py
文件中,您使用空字典调用main
,大概是为**settings
解压缩了该字典.您需要将适当的设置添加到要传递给函数的字典中,并且该字典应该可以运行. :)
In your test_cities_page.py
file you call main
with an empty dictionary, presumably to be unpacked for **settings
. You need to add the appropriate setting to the dictionary you're passing to the function and it should run. : )
这篇关于当同时使用webtest和sqlalchemy时,金字塔无法启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!