MCPcopy Index your code
hub / github.com/clips/pattern / test_deepcopy

Method test_deepcopy

test/test_graph.py:15–33  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

13 pass
14
15 def test_deepcopy(self):
16 # Object with a copy() method are responsible for deep-copying themselves.
17 class MyObject:
18 def __init__(self, i):
19 self.i = i
20 def copy(self):
21 return MyObject(graph.deepcopy(self.i))
22 # Assert deep copy for different types.
23 for o1 in (
24 None, True, False,
25 "a", u"a",
26 1, 1.0, 1L, complex(1),
27 list([1]), tuple([1]), set([1]), frozenset([1]),
28 dict(a=1), {frozenset(["a"]):1}, {MyObject(1):1},
29 MyObject(1)):
30 o2 = graph.deepcopy(o1)
31 if isinstance(o2, (list, tuple, set, dict, MyObject)):
32 self.assertTrue(id(o1) != id(o2))
33 print "pattern.graph.deepcopy()"
34
35 def test_unique(self):
36 # Assert list copy with unique items.

Callers

nothing calls this directly

Calls 1

MyObjectClass · 0.85

Tested by

no test coverage detected