How to use entrypoints - 10 common examples

To help you get started, we’ve selected a few entrypoints examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github takluyver / entrypoints / tests / test_entrypoints.py View on Github external
def test_case_sensitive(tmpdir):
    group = entrypoints.get_group_named('test.case_sensitive', sample_path)
    assert set(group.keys()) == {'Ptangle', 'ptangle'}
github takluyver / entrypoints / tests / test_entrypoints.py View on Github external
def test_parse_bad():
    with pytest.raises(entrypoints.BadEntryPoint):
        entrypoints.EntryPoint.from_string("this won't work", 'foo')
github takluyver / entrypoints / tests / test_entrypoints.py View on Github external
def test_parse():
    ep = entrypoints.EntryPoint.from_string(
        'some.module:some.attr [extra1,extra2]', 'foo'
    )
    assert ep.module_name == 'some.module'
    assert ep.object_name == 'some.attr'
    assert ep.extras == ['extra1', 'extra2']
github takluyver / entrypoints / tests / test_entrypoints.py View on Github external
def test_load():
    ep = entrypoints.EntryPoint('get_ep', 'entrypoints', 'get_single', None)
    obj = ep.load()
    assert obj is entrypoints.get_single

    # The object part is optional (e.g. pytest plugins use just a module ref)
    ep = entrypoints.EntryPoint('ep_mod', 'entrypoints', None)
    obj = ep.load()
    assert obj is entrypoints
github takluyver / entrypoints / tests / test_entrypoints.py View on Github external
def test_load():
    ep = entrypoints.EntryPoint('get_ep', 'entrypoints', 'get_single', None)
    obj = ep.load()
    assert obj is entrypoints.get_single

    # The object part is optional (e.g. pytest plugins use just a module ref)
    ep = entrypoints.EntryPoint('ep_mod', 'entrypoints', None)
    obj = ep.load()
    assert obj is entrypoints
github takluyver / entrypoints / tests / test_entrypoints.py View on Github external
def test_bad(temp_cache_file):
    bad_path = [osp.join(samples_dir, 'packages3')]

    group = entrypoints.get_group_named('entrypoints.test1', bad_path)

    assert 'bad' not in group

    with pytest.raises(entrypoints.NoSuchEntryPoint):
        ep = entrypoints.get_single('entrypoints.test1', 'bad', bad_path)
github takluyver / entrypoints / tests / test_entrypoints.py View on Github external
def test_missing(temp_cache_file):
    with pytest.raises(entrypoints.NoSuchEntryPoint) as ec:
        entrypoints.get_single('no.such.group', 'no_such_name', sample_path)

    assert ec.value.group == 'no.such.group'
    assert ec.value.name == 'no_such_name'
github takluyver / entrypoints / tests / test_entrypoints.py View on Github external
def test_dot_prefix(temp_cache_file):
    ep = entrypoints.get_single('blogtool.parsers', '.rst', sample_path)
    assert ep.object_name == 'SomeClass.some_classmethod'
    assert ep.extras == ['reST']

    group = entrypoints.get_group_named('blogtool.parsers', sample_path)
    assert set(group.keys()) == {'.rst'}
github takluyver / entrypoints / tests / test_entrypoints.py View on Github external
def test_get_single(temp_cache_file):
    ep = entrypoints.get_single('entrypoints.test1', 'abc', sample_path)
    assert ep.module_name == 'foo'
    assert ep.object_name == 'abc'

    ep2 = entrypoints.get_single('entrypoints.test1', 'njn', sample_path)
    assert ep2.module_name == 'qux.extn'
    assert ep2.object_name == 'Njn.load'
github takluyver / entrypoints / tests / test_entrypoints.py View on Github external
def test_parse_bad():
    with pytest.raises(entrypoints.BadEntryPoint):
        entrypoints.EntryPoint.from_string("this won't work", 'foo')