Пример #1
0
def test_multiple_keys():
    d = {'a': 1, 'b': 2, 'c': 3}
    kab = mygetter('a', 'b')

    assert kab(d) == (1, 2)
Пример #2
0
def test_one_pos_index():
    s = 'abcde'
    i2 = mygetter(2)

    assert i2(s) == 'c'
Пример #3
0
def test_one_key():
    d = {'a': 1, 'b': 2, 'c': 3}
    ka = mygetter('a')

    assert ka(d) == 1
Пример #4
0
def test_multiple_indexes():
    s = 'abcde'
    i21 = mygetter(2, 1)

    assert i21(s) == ('c', 'b')
Пример #5
0
def test_one_neg_index():
    s = 'abcde'
    i2 = mygetter(-2)

    assert i2(s) == 'd'