Beispiel #1
0
def test_registry():
    r = Registry(default_field="banana")
    a = HasDefaults("a", {"banana": 123}, defaults_field=None)
    b = HasDefaults("b", {"banana": 123}, defaults_field=None)
    c = HasDefaults("c",
                    "tests.utils.test_misc.cantaloup",
                    defaults_field="apple")
    r.register(a)(2)
    assert r[a] == 2
    assert r[b] == 123
    assert r[c] == 456
    with pytest.raises(TypeError):
        print(HasDefaults("d", 123, defaults_field="apple"))
    with pytest.raises(KeyError):
        print(r["xyz"])
Beispiel #2
0
def test_registry():
    r = Registry(default_field='banana')
    a = HasDefaults('a', {'banana': 123}, defaults_field=None)
    b = HasDefaults('b', {'banana': 123}, defaults_field=None)
    c = HasDefaults('c',
                    'tests.utils.test_misc.cantaloup',
                    defaults_field='apple')
    r.register(a)(2)
    assert r[a] == 2
    assert r[b] == 123
    assert r[c] == 456
    with pytest.raises(TypeError):
        print(HasDefaults('d', 123, defaults_field='apple'))
    with pytest.raises(KeyError):
        print(r['xyz'])