def test_assert_immutable(clac_layers): simple_clac = CLAC(*clac_layers) with raises(ImmutableLayer): simple_clac['test_key'] = 'hello' with raises(ImmutableLayer): clac_layers[0]['test_key'] = 'Hello' with raises(ImmutableLayer): simple_clac.setdefault('test_key')
def test_setdefault(mutable_layers): mutable_clac = CLAC(*mutable_layers) unique = object() default = object() assert mutable_clac.get('new_key', default=default) is default assert mutable_clac.get('new_key', layer_name='beta', default=default) is default mutable_clac.setdefault('new_key', unique) assert mutable_clac.setdefault('new_key', 'acbde') is unique assert mutable_clac.get('new_key', default=default) is unique assert mutable_clac.get('new_key', layer_name='beta', default=default) is unique