Exemple #1
0
 def test_line_nooutput (self):
     sys.stdout = StringIO()
     s = debug.Spew(trace_names = ['foo'])
     f = sys._getframe()
     s(f, "line", None)
     lineno = f.f_lineno - 1 # -1 here since we called with frame f in the line above
     output = sys.stdout.getvalue()
     self.failUnlessEqual(output, "")
Exemple #2
0
 def test_line (self):
     sys.stdout = StringIO()
     s = debug.Spew()
     f = sys._getframe()
     s(f, "line", None)
     lineno = f.f_lineno - 1 # -1 here since we called with frame f in the line above
     output = sys.stdout.getvalue()
     self.failUnless("%s:%i" % (__name__, lineno) in output,
                     "Didn't find line %i in %s" % (lineno, output))
     self.failUnless("f=<frame object at" in output)
Exemple #3
0
 def test_line_nofile (self):
     sys.stdout = StringIO()
     s = debug.Spew()
     g = globals().copy()
     del g['__file__']
     f = eval("sys._getframe()", g)
     lineno = f.f_lineno
     s(f, "line", None)
     output = sys.stdout.getvalue()
     self.failUnless("[unknown]:%i" % lineno in output,
                     "Didn't find [unknown]:%i in %s" % (lineno, output))
     self.failUnless("VM instruction #" in output, output)
Exemple #4
0
 def test_line_global (self):
     global GLOBAL_VAR
     sys.stdout = StringIO()
     GLOBAL_VAR = debug.Spew()
     f = sys._getframe()
     GLOBAL_VAR(f, "line", None)
     lineno = f.f_lineno - 1 # -1 here since we called with frame f in the line above
     output = sys.stdout.getvalue()
     self.failUnless("%s:%i" % (__name__, lineno) in output,
                     "Didn't find line %i in %s" % (lineno, output))
     self.failUnless("f=<frame object at" in output)
     self.failUnless("GLOBAL_VAR" in f.f_globals)
     self.failUnless("GLOBAL_VAR=<evy.debug.Spew object at" in output)
     del GLOBAL_VAR