Esempio n. 1
0
def test_setitem_imm_custom_class():
    class C:
        def __init__(self, item):
            self.item = item

        def __eq__(self, other):
            return self.item == other.item

        def _lens_setitem(self, key, value):
            return C(value)

    assert s.setitem_immutable(C(1), 0, 2) == C(2)
Esempio n. 2
0
def test_setitem_imm_tuple():
    assert s.setitem_immutable((1, 2, 3), 0, 4) == (4, 2, 3)
Esempio n. 3
0
def test_setitem_imm_list():
    assert s.setitem_immutable([1, 2, 3], 0, 4) == [4, 2, 3]
Esempio n. 4
0
def test_setitem_imm_str():
    assert s.setitem_immutable('hello', 0, 'j') == 'jello'
Esempio n. 5
0
def test_setitem_imm_bytes():
    assert s.setitem_immutable(b'hello', 0, ord(b'j')) == b'jello'