Back to index

python3.2  3.2.2
Public Member Functions
test.test_sys_setprofile.ProfileHookTestCase Class Reference
Inheritance diagram for test.test_sys_setprofile.ProfileHookTestCase:
Inheritance graph
[legend]
Collaboration diagram for test.test_sys_setprofile.ProfileHookTestCase:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def new_watcher
def test_simple
def test_exception
def test_caught_exception
def test_caught_nested_exception
def test_nested_exception
def test_exception_in_except_clause
def test_exception_propogation
def test_raise_twice
def test_raise_reraise
def test_raise
def test_distant_exception
def test_generator
def test_stop_iteration
def check_events

Detailed Description

Definition at line 100 of file test_sys_setprofile.py.


Member Function Documentation

def test.test_sys_setprofile.TestCaseBase.check_events (   self,
  callable,
  expected 
) [inherited]

Definition at line 93 of file test_sys_setprofile.py.

00093 
00094     def check_events(self, callable, expected):
00095         events = capture_events(callable, self.new_watcher())
00096         if events != expected:
00097             self.fail("Expected events:\n%s\nReceived events:\n%s"
00098                       % (pprint.pformat(expected), pprint.pformat(events)))
00099 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 101 of file test_sys_setprofile.py.

00101 
00102     def new_watcher(self):
00103         return HookWatcher()

Here is the caller graph for this function:

Definition at line 120 of file test_sys_setprofile.py.

00120 
00121     def test_caught_exception(self):
00122         def f(p):
00123             try: 1/0
00124             except: pass
00125         f_ident = ident(f)
00126         self.check_events(f, [(1, 'call', f_ident),
00127                               (1, 'return', f_ident),
00128                               ])

Here is the call graph for this function:

Definition at line 129 of file test_sys_setprofile.py.

00129 
00130     def test_caught_nested_exception(self):
00131         def f(p):
00132             try: 1/0
00133             except: pass
00134         f_ident = ident(f)
00135         self.check_events(f, [(1, 'call', f_ident),
00136                               (1, 'return', f_ident),
00137                               ])

Here is the call graph for this function:

Definition at line 209 of file test_sys_setprofile.py.

00209 
00210     def test_distant_exception(self):
00211         def f():
00212             1/0
00213         def g():
00214             f()
00215         def h():
00216             g()
00217         def i():
00218             h()
00219         def j(p):
00220             i()
00221         f_ident = ident(f)
00222         g_ident = ident(g)
00223         h_ident = ident(h)
00224         i_ident = ident(i)
00225         j_ident = ident(j)
00226         self.check_events(j, [(1, 'call', j_ident),
00227                               (2, 'call', i_ident),
00228                               (3, 'call', h_ident),
00229                               (4, 'call', g_ident),
00230                               (5, 'call', f_ident),
00231                               (5, 'return', f_ident),
00232                               (4, 'return', g_ident),
00233                               (3, 'return', h_ident),
00234                               (2, 'return', i_ident),
00235                               (1, 'return', j_ident),
00236                               ])

Here is the call graph for this function:

Definition at line 112 of file test_sys_setprofile.py.

00112 
00113     def test_exception(self):
00114         def f(p):
00115             1/0
00116         f_ident = ident(f)
00117         self.check_events(f, [(1, 'call', f_ident),
00118                               (1, 'return', f_ident),
00119                               ])

Here is the call graph for this function:

Definition at line 149 of file test_sys_setprofile.py.

00149 
00150     def test_exception_in_except_clause(self):
00151         def f(p):
00152             1/0
00153         def g(p):
00154             try:
00155                 f(p)
00156             except:
00157                 try: f(p)
00158                 except: pass
00159         f_ident = ident(f)
00160         g_ident = ident(g)
00161         self.check_events(g, [(1, 'call', g_ident),
00162                               (2, 'call', f_ident),
00163                               (2, 'return', f_ident),
00164                               (3, 'call', f_ident),
00165                               (3, 'return', f_ident),
00166                               (1, 'return', g_ident),
00167                               ])

Here is the call graph for this function:

Definition at line 168 of file test_sys_setprofile.py.

00168 
00169     def test_exception_propogation(self):
00170         def f(p):
00171             1/0
00172         def g(p):
00173             try: f(p)
00174             finally: p.add_event("falling through")
00175         f_ident = ident(f)
00176         g_ident = ident(g)
00177         self.check_events(g, [(1, 'call', g_ident),
00178                               (2, 'call', f_ident),
00179                               (2, 'return', f_ident),
00180                               (1, 'falling through', g_ident),
00181                               (1, 'return', g_ident),
00182                               ])

Here is the call graph for this function:

Definition at line 237 of file test_sys_setprofile.py.

00237 
00238     def test_generator(self):
00239         def f():
00240             for i in range(2):
00241                 yield i
00242         def g(p):
00243             for i in f():
00244                 pass
00245         f_ident = ident(f)
00246         g_ident = ident(g)
00247         self.check_events(g, [(1, 'call', g_ident),
00248                               # call the iterator twice to generate values
00249                               (2, 'call', f_ident),
00250                               (2, 'return', f_ident),
00251                               (2, 'call', f_ident),
00252                               (2, 'return', f_ident),
00253                               # once more; returns end-of-iteration with
00254                               # actually raising an exception
00255                               (2, 'call', f_ident),
00256                               (2, 'return', f_ident),
00257                               (1, 'return', g_ident),
00258                               ])

Here is the call graph for this function:

Definition at line 138 of file test_sys_setprofile.py.

00138 
00139     def test_nested_exception(self):
00140         def f(p):
00141             1/0
00142         f_ident = ident(f)
00143         self.check_events(f, [(1, 'call', f_ident),
00144                               # This isn't what I expected:
00145                               # (0, 'exception', protect_ident),
00146                               # I expected this again:
00147                               (1, 'return', f_ident),
00148                               ])

Here is the call graph for this function:

Definition at line 201 of file test_sys_setprofile.py.

00201 
00202     def test_raise(self):
00203         def f(p):
00204             raise Exception()
00205         f_ident = ident(f)
00206         self.check_events(f, [(1, 'call', f_ident),
00207                               (1, 'return', f_ident),
00208                               ])

Here is the call graph for this function:

Definition at line 192 of file test_sys_setprofile.py.

00192 
00193     def test_raise_reraise(self):
00194         def f(p):
00195             try: 1/0
00196             except: raise
00197         f_ident = ident(f)
00198         self.check_events(f, [(1, 'call', f_ident),
00199                               (1, 'return', f_ident),
00200                               ])

Here is the call graph for this function:

Definition at line 183 of file test_sys_setprofile.py.

00183 
00184     def test_raise_twice(self):
00185         def f(p):
00186             try: 1/0
00187             except: 1/0
00188         f_ident = ident(f)
00189         self.check_events(f, [(1, 'call', f_ident),
00190                               (1, 'return', f_ident),
00191                               ])

Here is the call graph for this function:

Definition at line 104 of file test_sys_setprofile.py.

00104 
00105     def test_simple(self):
00106         def f(p):
00107             pass
00108         f_ident = ident(f)
00109         self.check_events(f, [(1, 'call', f_ident),
00110                               (1, 'return', f_ident),
00111                               ])

Definition at line 259 of file test_sys_setprofile.py.

00259 
00260     def test_stop_iteration(self):
00261         def f():
00262             for i in range(2):
00263                 yield i
00264             raise StopIteration
00265         def g(p):
00266             for i in f():
00267                 pass
00268         f_ident = ident(f)
00269         g_ident = ident(g)
00270         self.check_events(g, [(1, 'call', g_ident),
00271                               # call the iterator twice to generate values
00272                               (2, 'call', f_ident),
00273                               (2, 'return', f_ident),
00274                               (2, 'call', f_ident),
00275                               (2, 'return', f_ident),
00276                               # once more to hit the raise:
00277                               (2, 'call', f_ident),
00278                               (2, 'return', f_ident),
00279                               (1, 'return', g_ident),
00280                               ])
00281 

Here is the call graph for this function:


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