Back to index

python3.2  3.2.2
Classes | Functions | Variables
test.test_sys_setprofile Namespace Reference

Classes

class  TestGetProfile
class  HookWatcher
class  ProfileSimulator
class  TestCaseBase
class  ProfileHookTestCase
class  ProfileSimulatorTestCase

Functions

def ident
def protect
def capture_events
def show_events
def test_main

Variables

tuple protect_ident = ident(protect)

Function Documentation

def test.test_sys_setprofile.capture_events (   callable,
  p = None 
)

Definition at line 355 of file test_sys_setprofile.py.

00355 
00356 def capture_events(callable, p=None):
00357     if p is None:
00358         p = HookWatcher()
00359     # Disable the garbage collector. This prevents __del__s from showing up in
00360     # traces.
00361     old_gc = gc.isenabled()
00362     gc.disable()
00363     try:
00364         sys.setprofile(p.callback)
00365         protect(callable, p)
00366         sys.setprofile(None)
00367     finally:
00368         if old_gc:
00369             gc.enable()
00370     return p.get_events()[1:-1]
00371 

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_sys_setprofile.ident (   function)

Definition at line 340 of file test_sys_setprofile.py.

00340 
00341 def ident(function):
00342     if hasattr(function, "f_code"):
00343         code = function.f_code
00344     else:
00345         code = function.__code__
00346     return code.co_firstlineno, code.co_name
00347 

Here is the caller graph for this function:

def test.test_sys_setprofile.protect (   f,
  p 
)

Definition at line 348 of file test_sys_setprofile.py.

00348 
00349 def protect(f, p):
00350     try: f(p)
00351     except: pass

Here is the caller graph for this function:

Definition at line 372 of file test_sys_setprofile.py.

00372 
00373 def show_events(callable):
00374     import pprint
00375     pprint.pprint(capture_events(callable))
00376 

Here is the call graph for this function:

Definition at line 377 of file test_sys_setprofile.py.

00377 
00378 def test_main():
00379     support.run_unittest(
00380         TestGetProfile,
00381         ProfileHookTestCase,
00382         ProfileSimulatorTestCase
00383     )
00384 


Variable Documentation

Definition at line 352 of file test_sys_setprofile.py.