Exemplo n.º 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))
Exemplo n.º 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)
Exemplo n.º 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))
Exemplo n.º 4
0
def test_namespace_no_promote_overwrite_backwards():
    x = Namespace(x__z=42)
    x.setitem_path('x', 17)
    assert x == Namespace(x=17)
Exemplo n.º 5
0
def test_namespace_no_promote_overwrite():
    x = Namespace(x=17)
    x.setitem_path('x__z', 42)
    assert x == Namespace(x__z=42)
Exemplo n.º 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))
Exemplo n.º 7
0
def test_namespace_setitem_split_path():
    x = Namespace()
    x.setitem_path('x__y', 17)
    assert x == dict(x=dict(y=17))
Exemplo n.º 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))
Exemplo n.º 9
0
def test_namespace_setitem_singe_value_overwrite():
    x = Namespace(x=17)
    x.setitem_path('x', 42)
    assert x == dict(x=42)
Exemplo n.º 10
0
def test_namespace_setitem_single_value():
    x = Namespace()
    x.setitem_path('x', 17)
    assert x == dict(x=17)
Exemplo n.º 11
0
def test_namespace_setitem_function_non_dict():
    x = Namespace(f=f)
    x.setitem_path('f', 17)
    assert dict(f=17) == x
Exemplo n.º 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
Exemplo n.º 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