예제 #1
0
 def test_simple_chain(self):
     edge_fn = edge_function({'A': 'B'})
     output = StringIO()
     objgraph._show_graph([TestObject.get("A")], edge_fn, False,
                          output=output, shortnames=True)
     output_value = output.getvalue()
     label_a = objgraph._obj_node_id(TestObject.get("A"))
     label_b = objgraph._obj_node_id(TestObject.get("B"))
     self.assertEqual(output_value,
                      format(TWO_ELEMENT_OUTPUT,
                             label_a=label_a,
                             label_b=label_b))
예제 #2
0
 def test_cull_func(self):
     edge_fn = edge_function({'A': 'B', 'B': 'C'})
     output = StringIO()
     objgraph._show_graph([TestObject.get("A")],
                          edge_fn,
                          False,
                          output=output,
                          shortnames=True,
                          cull_func=lambda obj: obj.name == 'B')
     output_value = output.getvalue()
     label_a = objgraph._obj_node_id(TestObject.get("A"))
     label_b = objgraph._obj_node_id(TestObject.get("B"))
     self.assertEqual(
         output_value,
         format(TWO_ELEMENT_OUTPUT, label_a=label_a, label_b=label_b))
예제 #3
0
 def test_basic_file_output(self):
     obj = TestObject()
     output = StringIO()
     objgraph._show_graph([obj], empty_edge_function, False, output=output)
     output_value = output.getvalue()
     self.assertRegex(output_value, r'digraph ObjectGraph')
     self.assertRegex(output_value,
                      r'%s\[.*?\]' % objgraph._obj_node_id(obj))
예제 #4
0
 def test_basic_file_output(self):
     obj = TestObject.get("A")
     output = StringIO()
     objgraph._show_graph([obj], edge_function(), False, output=output,
                          shortnames=True)
     output_value = output.getvalue()
     label = objgraph._obj_node_id(obj)
     self.assertEqual(output_value,
                      format(SINGLE_ELEMENT_OUTPUT,
                             label_a=label))
예제 #5
0
 def test_basic_file_output(self):
     obj = TestObject.get("A")
     output = StringIO()
     objgraph._show_graph([obj], edge_function(), False, output=output,
                          shortnames=True)
     output_value = output.getvalue()
     label = objgraph._obj_node_id(obj)
     self.assertEqual(output_value,
                      format(SINGLE_ELEMENT_OUTPUT,
                             label_a=label))
예제 #6
0
 def test_with_extra_node_attrs(self):
     obj = TestObject.get("A")
     output = StringIO()
     objgraph._show_graph([obj],
                          edge_function(),
                          False,
                          output=output,
                          shortnames=True,
                          extra_node_attrs=lambda o: {'x': 'y'})
     output_value = output.getvalue()
     label = objgraph._obj_node_id(obj)
     self.assertEqual(
         output_value, format(SINGLE_ELEMENT_OUTPUT_WITH_ATTR,
                              label_a=label))