Search code examples
pythonflaskflask-testing

Flask-Testing signals not supported error


When running my tests I am getting the following traceback.

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)

It appears that the get_context_variable function call is where the error is coming from. I also receive this error if I try and use assert_template_used. Having a rather difficult time finding any resolution to this.


Solution

  • Flask only provides signals as an optional dependency. Flask-Testing requires signals in some places and raises an error if you try to do something without them. For some reason, some messages are more vague than others Flask-Testing raises elsewhere. (This is a good place for a beginner to contribute a pull request.)

    You need to install the blinker library to enable signal support in Flask.

    $ pip install blinker