Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
test.test_trace.TestLineCounts Class Reference

List of all members.

Public Member Functions

def setUp
def test_traced_func_linear
def test_traced_func_loop
def test_traced_func_importing
def test_trace_func_generator
def test_trace_list_comprehension
def test_linear_methods

Public Attributes

 tracer
 my_py_filename

Detailed Description

White-box testing of line-counting, via runfunc

Definition at line 102 of file test_trace.py.


Member Function Documentation

Definition at line 104 of file test_trace.py.

00104 
00105     def setUp(self):
00106         self.tracer = Trace(count=1, trace=0, countfuncs=0, countcallers=0)
00107         self.my_py_filename = fix_ext_py(__file__)

Here is the caller graph for this function:

Definition at line 175 of file test_trace.py.

00175 
00176     def test_linear_methods(self):
00177         # XXX todo: later add 'static_method_linear' and 'class_method_linear'
00178         # here, once issue1764286 is resolved
00179         #
00180         for methname in ['inst_method_linear',]:
00181             tracer = Trace(count=1, trace=0, countfuncs=0, countcallers=0)
00182             traced_obj = TracedClass(25)
00183             method = getattr(traced_obj, methname)
00184             tracer.runfunc(method, 20)
00185 
00186             firstlineno = get_firstlineno(method)
00187             expected = {
00188                 (self.my_py_filename, firstlineno + 1): 1,
00189             }
00190             self.assertEqual(tracer.results().counts, expected)

Here is the call graph for this function:

Definition at line 144 of file test_trace.py.

00144 
00145     def test_trace_func_generator(self):
00146         self.tracer.runfunc(traced_func_calling_generator)
00147 
00148         firstlineno_calling = get_firstlineno(traced_func_calling_generator)
00149         firstlineno_gen = get_firstlineno(traced_func_generator)
00150         expected = {
00151             (self.my_py_filename, firstlineno_calling + 1): 1,
00152             (self.my_py_filename, firstlineno_calling + 2): 11,
00153             (self.my_py_filename, firstlineno_calling + 3): 10,
00154             (self.my_py_filename, firstlineno_gen + 1): 1,
00155             (self.my_py_filename, firstlineno_gen + 2): 11,
00156             (self.my_py_filename, firstlineno_gen + 3): 10,
00157         }
00158         self.assertEqual(self.tracer.results().counts, expected)

Here is the call graph for this function:

Definition at line 159 of file test_trace.py.

00159 
00160     def test_trace_list_comprehension(self):
00161         self.tracer.runfunc(traced_caller_list_comprehension)
00162 
00163         firstlineno_calling = get_firstlineno(traced_caller_list_comprehension)
00164         firstlineno_called = get_firstlineno(traced_doubler)
00165         expected = {
00166             (self.my_py_filename, firstlineno_calling + 1): 1,
00167             # List compehentions work differently in 3.x, so the count
00168             # below changed compared to 2.x.
00169             (self.my_py_filename, firstlineno_calling + 2): 12,
00170             (self.my_py_filename, firstlineno_calling + 3): 1,
00171             (self.my_py_filename, firstlineno_called + 1): 10,
00172         }
00173         self.assertEqual(self.tracer.results().counts, expected)
00174 

Here is the call graph for this function:

Definition at line 132 of file test_trace.py.

00132 
00133     def test_traced_func_importing(self):
00134         self.tracer.runfunc(traced_func_importing, 2, 5)
00135 
00136         firstlineno = get_firstlineno(traced_func_importing)
00137         expected = {
00138             (self.my_py_filename, firstlineno + 1): 1,
00139             (fix_ext_py(testmod.__file__), 2): 1,
00140             (fix_ext_py(testmod.__file__), 3): 1,
00141         }
00142 
00143         self.assertEqual(self.tracer.results().counts, expected)

Here is the call graph for this function:

Definition at line 108 of file test_trace.py.

00108 
00109     def test_traced_func_linear(self):
00110         result = self.tracer.runfunc(traced_func_linear, 2, 5)
00111         self.assertEqual(result, 7)
00112 
00113         # all lines are executed once
00114         expected = {}
00115         firstlineno = get_firstlineno(traced_func_linear)
00116         for i in range(1, 5):
00117             expected[(self.my_py_filename, firstlineno +  i)] = 1
00118 
00119         self.assertEqual(self.tracer.results().counts, expected)

Here is the call graph for this function:

Definition at line 120 of file test_trace.py.

00120 
00121     def test_traced_func_loop(self):
00122         self.tracer.runfunc(traced_func_loop, 2, 3)
00123 
00124         firstlineno = get_firstlineno(traced_func_loop)
00125         expected = {
00126             (self.my_py_filename, firstlineno + 1): 1,
00127             (self.my_py_filename, firstlineno + 2): 6,
00128             (self.my_py_filename, firstlineno + 3): 5,
00129             (self.my_py_filename, firstlineno + 4): 1,
00130         }
00131         self.assertEqual(self.tracer.results().counts, expected)

Here is the call graph for this function:


Member Data Documentation

Definition at line 106 of file test_trace.py.

Definition at line 105 of file test_trace.py.


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