示例#1
0
def test_namespace_setitem_function_dict():
    def f():
        pass

    x = Namespace(f=f)
    x.setitem_path('f', dict(x=17))
    assert x == dict(f=dict(call_target=f, x=17))
示例#2
0
def test_namespace_setitem_function_non_dict():
    def f():
        pass

    x = Namespace(f=f)
    x.setitem_path('f', 17)
    assert x == dict(f=17)
示例#3
0
def test_namespace_setitem_function_backward():
    def f():
        pass

    x = Namespace(f__x=17)
    x.setitem_path('f', f)
    assert x == dict(f=dict(call_target=f, x=17))
示例#4
0
def test_namespace_no_promote_overwrite_backwards():
    x = Namespace(x__z=42)
    x.setitem_path('x', 17)
    assert x == Namespace(x=17)
示例#5
0
def test_namespace_no_promote_overwrite():
    x = Namespace(x=17)
    x.setitem_path('x__z', 42)
    assert x == Namespace(x__z=42)
示例#6
0
def test_namespace_setitem_namespace_merge():
    x = Namespace(x__y=17)
    x.setitem_path('x__z', 42)
    assert x == dict(x=dict(y=17, z=42))
示例#7
0
def test_namespace_setitem_split_path():
    x = Namespace()
    x.setitem_path('x__y', 17)
    assert x == dict(x=dict(y=17))
示例#8
0
def test_namespace_setitem_split_path_overwrite():
    x = Namespace(x__y=17)
    x.setitem_path('x__y', 42)
    assert x == dict(x=dict(y=42))
示例#9
0
def test_namespace_setitem_singe_value_overwrite():
    x = Namespace(x=17)
    x.setitem_path('x', 42)
    assert x == dict(x=42)
示例#10
0
def test_namespace_setitem_single_value():
    x = Namespace()
    x.setitem_path('x', 17)
    assert x == dict(x=17)
示例#11
0
def test_namespace_setitem_function_non_dict():
    x = Namespace(f=f)
    x.setitem_path('f', 17)
    assert dict(f=17) == x
示例#12
0
def test_namespace_setitem_function():
    x = Namespace(f=f)
    x.setitem_path('f__x', 17)
    assert dict(f=dict(call_target=f, x=17)) == x
示例#13
0
def test_namespace_setitem_promote_string_to_namespace():
    x = Namespace(x='y')
    x.setitem_path('x__z', 17)
    assert dict(x=dict(y=True, z=17)) == x