Пример #1
0
def test_get_in_not_in():
    assert_equal(List([Dict({1: 1})]).get_in(1, 1), None)
Пример #2
0
def test_update_in():
    assert_equal(
        List([Dict({1: 1})]).update_in(0, 1, to=2), List([Dict({1: 2})]))
Пример #3
0
def test_get_in():
    assert_equal(List([Dict({1: 1})]).get_in(0, 1), 1)
Пример #4
0
def test_pick():
    d = Dict({1: 2, 3: 4, 5: 6})
    assert_equal(d.pick(1, 5), Dict({1: 2, 5: 6}))
Пример #5
0
def test_reset():
    reset = Dict({2: 1, 4: 3})
    assert_equal(Dict({1: 2, 3: 4}).reset(reset), reset)
Пример #6
0
def test_reduce():
    assert_equal(
        Dict({
            1: 2,
            3: 4
        }).reduce(lambda acc, k, v: acc + k + v, 0), 10)
Пример #7
0
def test_reduce_no_acc():
    assert_equal(
        Dict({
            1: 2,
            3: 4
        }).reduce(lambda acc, k, v: acc + (k, v)), (1, 2, 3, 4))
Пример #8
0
def test_remove_empty_custom_fun():
    assert_equal(
        Dict({
            1: 2,
            4: 3
        }).remove_empty(fun=lambda x: x != 3), Dict({1: 2}))
Пример #9
0
def test_reverse():
    assert_equal(Dict({1: 2, 3: 4}).reverse(), Dict({2: 1, 4: 3}))
Пример #10
0
def test_remove_empty_keys():
    assert_equal(
        Dict({
            1: 2,
            None: 3
        }).remove_empty(filter_keys=True), Dict({1: 2}))
Пример #11
0
def test_remove_empty():
    assert_equal(Dict({1: 2, 3: None}).remove_empty(), Dict({1: 2}))
Пример #12
0
def test_update():
    assert_equal(Dict({1: 2, 3: 4}).update({2: 3}), Dict({1: 2, 2: 3, 3: 4}))
Пример #13
0
def test_setdefault():
    d = Dict({2: 1, 4: 3})
    assert_equal(d.setdefault(1), d)
Пример #14
0
def test_clear():
    assert_equal(Dict({1: 2, 3: 4}).clear(), Dict({}))