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

Method test_copy

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

Source from the content-addressed store, hash-verified

298 print "pattern.graph.Graph.update()"
299
300 def test_copy(self):
301 # Assert deep copy of Graph.
302 g1 = self.g
303 g2 = self.g.copy()
304 self.assertTrue(set(g1) == set(g2)) # Same node id's.
305 self.assertTrue(id(g1["a"]) != id(g2["b"])) # Different node objects.
306 g3 = self.g.copy(nodes=[self.g["a"], self.g["b"]])
307 g3 = self.g.copy(nodes=["a", "b"])
308 self.assertTrue(len(g3.nodes), 2)
309 self.assertTrue(len(g3.edges), 1)
310 # Assert copy with subclasses of Node and Edge.
311 class MyNode(graph.Node):
312 pass
313 class MyEdge(graph.Edge):
314 pass
315 g4 = graph.Graph()
316 g4.append(MyNode, "a")
317 g4.append(MyNode, "b")
318 g4.append(MyEdge, "a", "b")
319 g4 = g4.copy()
320 self.assertTrue(isinstance(g4.nodes[0], MyNode))
321 self.assertTrue(isinstance(g4.edges[0], MyEdge))
322 print "pattern.graph.Graph.copy()"
323
324#---------------------------------------------------------------------------------------------------
325

Callers

nothing calls this directly

Calls 4

appendMethod · 0.95
copyMethod · 0.95
lenFunction · 0.85
copyMethod · 0.45

Tested by

no test coverage detected