更新:最初我没有意识到这只会在从单元测试运行时失败。
我用python在appengine中有一个工作任务队列。
-手动调用视图时,任务将添加到队列并运行
-从单元测试调用时,将任务添加到队列失败,并出现未知队列错误。
在阅读其他遇到this问题的人时,有一些建议覆盖taskqueue_stub来解决这个问题。但我不知道该怎么做,为什么。

最佳答案

编辑:工作答案。我的问题是在单个单元测试中添加存根修复:将其移动到setup()修复了一些问题。
在tests.py中

from google.appengine.api import apiproxy_stub_map
import os

class BlahTest(MyAppTestCase)
    def setUp(self):
        '''Ensure dev appserver task queue knows where to find queue.yaml'''
        taskqueue_stub = apiproxy_stub_map.apiproxy.GetStub( 'taskqueue' )
        dircontainingqueuedotyaml = os.path.dirname(os.path.dirname( __file__ ))
        taskqueue_stub._root_path = dircontainingqueuedotyaml

现在可以了。

10-07 19:00
查看更多