def test_present_xdot(self): self.programsInPath(['xdot']) objgraph._present_graph('foo.dot') self.assertOutput(""" Spawning graph viewer (xdot) subprocess.Popen(['xdot', 'foo.dot']) """)
def test_present_png_no_dot(self): self.programsInPath([]) objgraph._present_graph('foo.dot', 'bar.png') self.assertOutput(""" Image renderer (dot) not found, not doing anything else """) self.assertFalse(os.path.exists('bar.png'))
def test_present_png(self): self.programsInPath(['dot']) objgraph._present_graph('foo.dot', 'bar.png') self.assertOutput(""" subprocess.Popen(['dot', '-Tpng', '-obar.png', 'foo.dot']) Image generated as bar.png """)
def test_present_no_xdot(self): self.programsInPath(['dot']) objgraph._present_graph('foo.dot') self.assertOutput(""" Graph viewer (xdot) not found, generating a png instead subprocess.Popen(['dot', '-Tpng', '-ofoo.png', 'foo.dot']) Image generated as foo.png """)
def test_present_png_failure(self): self.programsInPath(['dot']) objgraph.subprocess.should_fail = True objgraph._present_graph('f.dot', 'b.png') self.assertOutput(""" subprocess.Popen(['dot', '-Tpng', '-ob.png', 'f.dot']) dot failed (exit code 1) while executing "dot -Tpng -ob.png f.dot" """)
def test_present_no_xdot_and_no_not(self): self.programsInPath([]) objgraph._present_graph('foo.dot') self.assertOutput("Graph viewer (xdot) and image renderer (dot)" " not found, not doing anything else\n")
def test_present_dot(self): objgraph._present_graph('foo.dot', 'foo.dot') self.assertOutput("")