2016-07-20 49 views
3

运行我的测试时,我得到以下回溯。不支持瓶测试信号错误

in get_context_variable 
raise RuntimeError("Signals not supported") 
RuntimeError: Signals not supported 

__init__.py

from flask_testing import TestCase 

from app import create_app, db 


class BaseTest(TestCase): 
    BASE_URL = 'http://localhost:5000/' 

    def create_app(self): 
     return create_app('testing') 

    def setUp(self): 
     db.create_all() 

    def tearDown(self): 
     db.session.remove() 
     db.drop_all() 

    def test_setup(self): 
     response = self.client.get(self.BASE_URL) 
     self.assertEqual(response.status_code, 200) 

test_routes.py

from . import BaseTest 


class TestMain(BaseTest): 

    def test_empty_index(self): 
     r = self.client.get('/') 
     self.assert200(r) 
     self.assertEqual(self.get_context_variable('partners'), None) 

看来,get_context_variable函数调用就是错误的来源。如果我尝试并使用assert_template_used,我也会收到此错误。找到任何解决方案相当困难。

回答

5

Flask仅提供信号作为可选依赖项。 Flask-Testing需要在某些地方发出信号,并且如果您尝试在没有它们的情况下执行某些操作,则会产生错误。出于某种原因,某些消息比其他消息更模糊Flask-Testing在别处引发。 (这是一个初学者贡献pull请求的好地方。)

您需要安装blinker库启用瓶signal support

$ pip install blinker