Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
test.test_sys_settrace.TraceTestCase Class Reference

List of all members.

Public Member Functions

def setUp
def tearDown
def compare_events
def run_and_compare
def run_test
def run_test2
def set_and_retrieve_none
def set_and_retrieve_func
def test_01_basic
def test_02_arigo
def test_03_one_instr
def test_04_no_pop_blocks
def test_05_no_pop_tops
def test_06_call
def test_07_raise
def test_08_settrace_and_return
def test_09_settrace_and_raise
def test_10_ireturn
def test_11_tightloop
def test_12_tighterloop
def test_13_genexp
def test_14_onliner_if
def test_15_loops
def test_16_blank_lines

Public Attributes

 using_gc

Detailed Description

Definition at line 247 of file test_sys_settrace.py.


Member Function Documentation

def test.test_sys_settrace.TraceTestCase.compare_events (   self,
  line_offset,
  events,
  expected_events 
)

Definition at line 259 of file test_sys_settrace.py.

00259 
00260     def compare_events(self, line_offset, events, expected_events):
00261         events = [(l - line_offset, e) for (l, e) in events]
00262         if events != expected_events:
00263             self.fail(
00264                 "events did not match expectation:\n" +
00265                 "\n".join(difflib.ndiff([str(x) for x in expected_events],
00266                                         [str(x) for x in events])))

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_sys_settrace.TraceTestCase.run_and_compare (   self,
  func,
  events 
)

Definition at line 267 of file test_sys_settrace.py.

00267 
00268     def run_and_compare(self, func, events):
00269         tracer = Tracer()
00270         sys.settrace(tracer.trace)
00271         func()
00272         sys.settrace(None)
00273         self.compare_events(func.__code__.co_firstlineno,
00274                             tracer.events, events)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 275 of file test_sys_settrace.py.

00275 
00276     def run_test(self, func):
00277         self.run_and_compare(func, func.events)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 278 of file test_sys_settrace.py.

00278 
00279     def run_test2(self, func):
00280         tracer = Tracer()
00281         func(tracer.trace)
00282         sys.settrace(None)
00283         self.compare_events(func.__code__.co_firstlineno,
00284                             tracer.events, func.events)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 289 of file test_sys_settrace.py.

00289 
00290     def set_and_retrieve_func(self):
00291         def fn(*args):
00292             pass
00293 
00294         sys.settrace(fn)
00295         try:
00296             assert sys.gettrace() is fn
00297         finally:
00298             sys.settrace(None)

Definition at line 285 of file test_sys_settrace.py.

00285 
00286     def set_and_retrieve_none(self):
00287         sys.settrace(None)
00288         assert sys.gettrace() is None

Definition at line 251 of file test_sys_settrace.py.

00251 
00252     def setUp(self):
00253         self.using_gc = gc.isenabled()
00254         gc.disable()

Here is the caller graph for this function:

Definition at line 255 of file test_sys_settrace.py.

00255 
00256     def tearDown(self):
00257         if self.using_gc:
00258             gc.enable()

Here is the caller graph for this function:

Definition at line 299 of file test_sys_settrace.py.

00299 
00300     def test_01_basic(self):
        self.run_test(basic)

Here is the call graph for this function:

Definition at line 301 of file test_sys_settrace.py.

00301 
00302     def test_02_arigo(self):
        self.run_test(arigo_example)

Here is the call graph for this function:

Definition at line 303 of file test_sys_settrace.py.

00303 
00304     def test_03_one_instr(self):
        self.run_test(one_instr_line)

Here is the call graph for this function:

Definition at line 305 of file test_sys_settrace.py.

00305 
00306     def test_04_no_pop_blocks(self):
        self.run_test(no_pop_blocks)

Here is the call graph for this function:

Definition at line 307 of file test_sys_settrace.py.

00307 
00308     def test_05_no_pop_tops(self):
        self.run_test(no_pop_tops)

Here is the call graph for this function:

Definition at line 309 of file test_sys_settrace.py.

00309 
00310     def test_06_call(self):
        self.run_test(call)

Here is the call graph for this function:

Definition at line 311 of file test_sys_settrace.py.

00311 
00312     def test_07_raise(self):
00313         self.run_test(test_raise)

Here is the call graph for this function:

Definition at line 314 of file test_sys_settrace.py.

00314 
00315     def test_08_settrace_and_return(self):
        self.run_test2(settrace_and_return)

Here is the call graph for this function:

Definition at line 316 of file test_sys_settrace.py.

00316 
00317     def test_09_settrace_and_raise(self):
        self.run_test2(settrace_and_raise)

Here is the call graph for this function:

Definition at line 318 of file test_sys_settrace.py.

00318 
00319     def test_10_ireturn(self):
        self.run_test(ireturn_example)

Here is the call graph for this function:

Definition at line 320 of file test_sys_settrace.py.

00320 
00321     def test_11_tightloop(self):
        self.run_test(tightloop_example)

Here is the call graph for this function:

Definition at line 322 of file test_sys_settrace.py.

00322 
00323     def test_12_tighterloop(self):
00324         self.run_test(tighterloop_example)

Here is the call graph for this function:

Definition at line 325 of file test_sys_settrace.py.

00325 
00326     def test_13_genexp(self):
00327         self.run_test(generator_example)
00328         # issue1265: if the trace function contains a generator,
00329         # and if the traced function contains another generator
00330         # that is not completely exhausted, the trace stopped.
00331         # Worse: the 'finally' clause was not invoked.
00332         tracer = Tracer()
00333         sys.settrace(tracer.traceWithGenexp)
00334         generator_example()
00335         sys.settrace(None)
00336         self.compare_events(generator_example.__code__.co_firstlineno,
00337                             tracer.events, generator_example.events)

Here is the call graph for this function:

Definition at line 338 of file test_sys_settrace.py.

00338 
00339     def test_14_onliner_if(self):
00340         def onliners():
00341             if True: False
00342             else: True
00343             return 0
00344         self.run_and_compare(
00345             onliners,
00346             [(0, 'call'),
00347              (1, 'line'),
00348              (3, 'line'),
00349              (3, 'return')])

Here is the call graph for this function:

Definition at line 350 of file test_sys_settrace.py.

00350 
00351     def test_15_loops(self):
00352         # issue1750076: "while" expression is skipped by debugger
00353         def for_example():
00354             for x in range(2):
00355                 pass
00356         self.run_and_compare(
00357             for_example,
00358             [(0, 'call'),
00359              (1, 'line'),
00360              (2, 'line'),
00361              (1, 'line'),
00362              (2, 'line'),
00363              (1, 'line'),
00364              (1, 'return')])
00365 
00366         def while_example():
00367             # While expression should be traced on every loop
00368             x = 2
00369             while x > 0:
00370                 x -= 1
00371         self.run_and_compare(
00372             while_example,
00373             [(0, 'call'),
00374              (2, 'line'),
00375              (3, 'line'),
00376              (4, 'line'),
00377              (3, 'line'),
00378              (4, 'line'),
00379              (3, 'line'),
00380              (3, 'return')])

Here is the call graph for this function:

Definition at line 381 of file test_sys_settrace.py.

00381 
00382     def test_16_blank_lines(self):
00383         namespace = {}
00384         exec("def f():\n" + "\n" * 256 + "    pass", namespace)
00385         self.run_and_compare(
00386             namespace["f"],
00387             [(0, 'call'),
00388              (257, 'line'),
00389              (257, 'return')])
00390 

Here is the call graph for this function:


Member Data Documentation

Definition at line 252 of file test_sys_settrace.py.


The documentation for this class was generated from the following file: