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)
def test_setitem_imm_tuple(): assert s.setitem_immutable((1, 2, 3), 0, 4) == (4, 2, 3)
def test_setitem_imm_list(): assert s.setitem_immutable([1, 2, 3], 0, 4) == [4, 2, 3]
def test_setitem_imm_str(): assert s.setitem_immutable('hello', 0, 'j') == 'jello'
def test_setitem_imm_bytes(): assert s.setitem_immutable(b'hello', 0, ord(b'j')) == b'jello'