def test_default_namespace_searching():
    ns = options.Namespace()
    ns.val = 0
    ns.foo = options.Bunch(foo=1, bar=2, baz=3, blorg=6)
    ns.bar = options.Bunch(foo=4, baz=5, bop=7, val=8)
    assert ns.val == 0, "Top namespace has priority"
    assert ns.foo == options.Bunch(foo=1, bar=2, baz=3, blorg=6)
    assert ns.foo.foo == 1
    assert ns.bar.foo == 4
    assert ns.baz == 5
    assert ns.blorg == 6
    
    try:
        ns['does not exist']
        assert False, "expected key error for missing item"
    except __HOLE__:
        pass
    
    del ns['val']
    
    assert ns.val == 8, "Now getting val from inner dict"
    
    del ns.bar.val
    
    try:
        a = ns['val']
        assert False, "expected exception for deleted item %s" % (ns)
    except KeyError:
        pass
    
    del ns.foo
    assert ns._sections == ['bar']
dataset/ETHPy150Open paver/paver/paver/tests/test_options.py/test_default_namespace_searching