gpt4 book ai didi

python - gae-sessions 和 nose 的错误

转载 作者:行者123 更新时间:2023-11-28 16:47:07 27 4
gpt4 key购买 nike

我在将 gae-session 添加到相对成熟的 GAE 应用程序时遇到了一些问题。我仔细阅读了自述文件并查看了演示。

首先,在使用 nose 和 nose-gae 运行测试时,仅将 gaesesions 目录添加到我的应用程序会导致以下错误:

Exception ImportError: 'No module named threading' in <bound method local.__del__ of <_threading_local.local object at 0x103e10628>> ignored

所有测试都运行良好,所以不是大问题,但表明有些地方不对。

接下来,如果我添加以下两行代码:

from gaesessions import get_current_session
session = get_current_session()

然后运行我的测试,然后我得到以下错误:

Traceback (most recent call last):
File "/Users/.../unit_tests.py", line 1421, in testParseFBRequest
data = tasks.parse_fb_request(sr)
File "/Users/.../tasks.py", line 220, in parse_fb_request
session = get_current_session()
File "/Users/.../gaesessions/__init__.py", line 36, in get_current_session
return _tls.current_session
File "/Library/.../python2.7/_threading_local.py", line 193, in __getattribute__
return object.__getattribute__(self, name)
AttributeError: 'local' object has no attribute 'current_session'

此错误不会发生在开发服务器上。

如有任何关于解决上述问题的建议,我们将不胜感激。

最佳答案

我遇到了同样的问题。问题似乎是 gae 测试台的行为与开发服务器不同。我不知 Prop 体细节,但最终通过添加解决了它

def setUp(self):
testbed.Testbed().activate()
# after activating the testbed:
from gaesessions import Session, set_current_session
set_current_session(Session())

关于python - gae-sessions 和 nose 的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12770163/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com