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))
def test_namespace_setitem_function_non_dict(): def f(): pass x = Namespace(f=f) x.setitem_path('f', 17) assert x == dict(f=17)
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))
def test_namespace_no_promote_overwrite_backwards(): x = Namespace(x__z=42) x.setitem_path('x', 17) assert x == Namespace(x=17)
def test_namespace_no_promote_overwrite(): x = Namespace(x=17) x.setitem_path('x__z', 42) assert x == Namespace(x__z=42)
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))
def test_namespace_setitem_split_path(): x = Namespace() x.setitem_path('x__y', 17) assert x == dict(x=dict(y=17))
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))
def test_namespace_setitem_singe_value_overwrite(): x = Namespace(x=17) x.setitem_path('x', 42) assert x == dict(x=42)
def test_namespace_setitem_single_value(): x = Namespace() x.setitem_path('x', 17) assert x == dict(x=17)
def test_namespace_setitem_function_non_dict(): x = Namespace(f=f) x.setitem_path('f', 17) assert dict(f=17) == x
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
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