示例#1
0
def test_load_extension_classes():
    with patch_iter_entry_points():
        with patch('mode.utils.imports.symbol_by_name') as sbn:
            assert list(load_extension_classes('foo')) == [
                EntrypointExtension('ep1', sbn.return_value),
                EntrypointExtension('ep2', sbn.return_value),
            ]

            sbn.assert_has_calls([call('foo:a'), call('bar:c')])
示例#2
0
def test_load_extension_classes():
    with patch_iter_entry_points():
        with patch("mode.utils.imports.symbol_by_name") as sbn:
            assert list(load_extension_classes("foo")) == [
                EntrypointExtension("ep1", sbn.return_value),
                EntrypointExtension("ep2", sbn.return_value),
            ]

            sbn.assert_has_calls([call("foo:a"), call("bar:c")])
示例#3
0
def _maybe_load_extension_classes(namespace: str = 'faust.codecs') -> None:
    if namespace not in _extensions_finalized:
        _extensions_finalized[namespace] = True
        codecs.update(
            {name: cls()
             for name, cls in load_extension_classes(namespace)})
示例#4
0
def test_load_extension_classes_syntax_error():
    with patch_iter_entry_points():
        with patch('mode.utils.imports.symbol_by_name') as sbn:
            sbn.side_effect = SyntaxError()
            with pytest.warns(UserWarning):
                assert list(load_extension_classes('foo')) == []