def init_backend(self, options=None):
        """Use options to create a new mailer backend."""
        options = get_config(options or {})

        backend_path = options.pop('backend', None)
        backend_class = import_path(backend_path)
        if backend_class is None:
            raise RuntimeError("Invalid backend: '%s'" % backend_path)

        return backend_class(**options)
Пример #2
0
    def init_backend(self, options=None):
        """Use options to create a new mailer backend."""
        options = get_config(options or {})

        backend_path = options.pop('backend', None)
        backend_class = import_path(backend_path)
        if backend_class is None:
            raise RuntimeError("Invalid backend: '%s'" % backend_path)

        return backend_class(**options)
Пример #3
0
def test_import_path_swallow_import_errors():
    assert import_path('no.such.path') is None
Пример #4
0
def test_import_path_returns_the_last_name_in_path():
    assert import_path('flask_mailer.util.import_path') is import_path
Пример #5
0
def test_import_path_returns_none_if_path_is_empty():
    assert import_path('') is None