def test_response_classes_need_to_be_callable(self):
        # This ensures that register_callback will catch
        # a custom response_class which is not really a class
        # or a callable function which could produce a class instance

        inst = Sijax()

        def try_response_class(response_class, should_succeed):
            success = False
            try:
                inst.register_callback("name", lambda r: r, response_class=response_class)
                success = True
            except SijaxError:
                pass

            self.assertEqual(should_succeed, success, "Failure for %s" % repr(response_class))

        try_response_class(BaseResponse, True)

        class CustomResponse(BaseResponse): pass
        try_response_class(CustomResponse, True)

        # A callable instead of a response class still works
        def response_factory(*args, **kwargs):
            return CustomResponse(*args, **kwargs)
        try_response_class(response_factory, True)

        # This works too, because None makes it use the default (BaseResponse)
        try_response_class(None, True)

        try_response_class('', False)
        try_response_class(14, False)
dataset/ETHPy150Open spantaleev/sijax-python/tests/sijax_tests.py/SijaxMainTestCase.test_response_classes_need_to_be_callable/original