Exemplo n.º 1
0
def test_subset():
    ns = Namespace(foo=1, bar=2, baz=3)
    attrs = {'foo', 'bar'}
    ss = subset(ns, attrs)
    assert ss.foo == 1
    assert ss.bar == 2
    assert 'baz' not in ss
Exemplo n.º 2
0
def test_subset_type():
    class Foo(object):

        def __init__(self, **kwargs):
            pass

    ns = Namespace(foo=1, bar=2, baz=3)
    ss = subset(ns, ['foo', 'bar'], Foo)

    assert isinstance(ss, Foo)