Kaydet (Commit) 076a63e6 authored tarafından Yoong Kang Lim's avatar Yoong Kang Lim Kaydeden (comit) Tim Graham

Fixed #24883 -- Added MigrationGraph.__repr__()

üst bf07ba52
...@@ -247,10 +247,14 @@ class MigrationGraph(object): ...@@ -247,10 +247,14 @@ class MigrationGraph(object):
node = stack.pop() node = stack.pop()
def __str__(self): def __str__(self):
return "Graph: %s nodes, %s edges" % ( return 'Graph: %s nodes, %s edges' % self._nodes_and_edges()
len(self.nodes),
sum(len(node.parents) for node in self.node_map.values()), def __repr__(self):
) nodes, edges = self._nodes_and_edges()
return '<%s: nodes=%s, edges=%s>' % (self.__class__.__name__, nodes, edges)
def _nodes_and_edges(self):
return len(self.nodes), sum(len(node.parents) for node in self.node_map.values())
def make_state(self, nodes=None, at_end=True, real_apps=None): def make_state(self, nodes=None, at_end=True, real_apps=None):
""" """
......
...@@ -283,3 +283,4 @@ class GraphTests(SimpleTestCase): ...@@ -283,3 +283,4 @@ class GraphTests(SimpleTestCase):
graph.add_dependency("app_a.0003", ("app_a", "0003"), ("app_b", "0002")) graph.add_dependency("app_a.0003", ("app_a", "0003"), ("app_b", "0002"))
self.assertEqual(force_text(graph), "Graph: 5 nodes, 3 edges") self.assertEqual(force_text(graph), "Graph: 5 nodes, 3 edges")
self.assertEqual(repr(graph), "<MigrationGraph: nodes=5, edges=3>")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment