2016-07-20 48 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