def test_copying(): # Check that ordered dicts are copyable, deepcopyable, picklable, # and have a repr/eval round-trip pairs = [('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)] od = OrderedDict(pairs) def check(dup): assert dup is not od assert dup == od check(od.copy()) check(copy.copy(od)) check(copy.deepcopy(od)) for proto in range(pickle.HIGHEST_PROTOCOL + 1): check(pickle.loads(pickle.dumps(od, proto))) check(eval(repr(od))) update_test = OrderedDict() update_test.update(od) check(update_test) check(OrderedDict(od))
def test_od_copy(): od = OrderedDict([('a', 'b'), ('c', 'd'), ('foo', object())]) new_od = od.copy() assert od == new_od assert od['foo'] is new_od['foo']
def test_od_copy(): od = OrderedDict([("a", "b"), ("c", "d"), ("foo", object())]) new_od = od.copy() assert od == new_od assert od["foo"] is new_od["foo"]