def test_registry_indexers(): reg = registry.Registry() reg.register('foo', 2) reg.register('bar', 4) reg.register('baz.quux', 8) asserts.are_equal(reg['foo'], 2) asserts.are_equal(reg['bar'], 4) asserts.are_equal(reg['baz.quux'], 8)
def test_registry_attributes(): reg = registry.Registry() reg.register('foo', 2) reg.register('bar', 4) reg.register('baz.quux', 8) asserts.are_equal(reg.foo, 2) asserts.are_equal(reg.bar, 4) asserts.are_equal(reg.baz__DOT__quux, 8)
def test_registry_unregister_with_nonexistent_key(): reg = registry.Registry() reg.unregister('foo') asserts.is_empty(reg)
def test_registry_unregister_with_present_key(): reg = registry.Registry() reg.register('foo', 4) asserts.are_equal(len(reg), 1) reg.unregister('foo') asserts.is_empty(reg)
def test_registry_values(): reg = registry.Registry() reg.register('foo', 2) reg.register('bar', 4) reg.register('baz.quux', 8) asserts.are_equal(reg.values(), [2, 4, 8])
def test_registry_keys(): reg = registry.Registry() reg.register('foo', 2) reg.register('bar', 4) reg.register('baz.quux', 8) asserts.are_equal(reg.keys(), ['foo', 'bar', 'baz.quux'])
def test_registry_register_with_len(): reg = registry.Registry() reg.register('foo', 2) reg.register('bar', 4) reg.register('baz.quux', 8) asserts.are_equal(len(reg), 3)
def test_registry_init(): reg = registry.Registry() asserts.is_empty(reg) asserts.is_empty(reg.keys()) asserts.is_empty(reg.values())