Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(19025)

Side by Side Diff: Lib/test/test_trace.py

Issue 10541: regrtest.py -T broken
Patch Set: Created 8 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Lib/trace.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import os 1 import os
2 import sys 2 import sys
3 from test.support import (run_unittest, TESTFN, rmtree, unlink, 3 from test.support import (run_unittest, TESTFN, rmtree, unlink,
4 captured_stdout) 4 captured_stdout)
5 import unittest 5 import unittest
6 6
7 import trace 7 import trace
8 from trace import CoverageResults, Trace 8 from trace import CoverageResults, Trace
9 9
10 from test.tracedmodules import testmod 10 from test.tracedmodules import testmod
11
12 11
13 #------------------------------- Utilities -----------------------------------# 12 #------------------------------- Utilities -----------------------------------#
14 13
15 def fix_ext_py(filename): 14 def fix_ext_py(filename):
16 """Given a .pyc/.pyo filename converts it to the appropriate .py""" 15 """Given a .pyc/.pyo filename converts it to the appropriate .py"""
17 if filename.endswith(('.pyc', '.pyo')): 16 if filename.endswith(('.pyc', '.pyo')):
18 filename = filename[:-1] 17 filename = filename[:-1]
19 return filename 18 return filename
20 19
21 def my_file_and_modname(): 20 def my_file_and_modname():
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 # 212 #
214 for k in expected.keys(): 213 for k in expected.keys():
215 self.assertEqual(self.tracer.results().counts[k], expected[k]) 214 self.assertEqual(self.tracer.results().counts[k], expected[k])
216 215
217 216
218 class TestFuncs(unittest.TestCase): 217 class TestFuncs(unittest.TestCase):
219 """White-box testing of funcs tracing""" 218 """White-box testing of funcs tracing"""
220 def setUp(self): 219 def setUp(self):
221 self.tracer = Trace(count=0, trace=0, countfuncs=1) 220 self.tracer = Trace(count=0, trace=0, countfuncs=1)
222 self.filemod = my_file_and_modname() 221 self.filemod = my_file_and_modname()
222 self._saved_tracefunc = sys.gettrace()
223
224 def tearDown(self):
225 if self._saved_tracefunc is not None:
226 sys.settrace(self._saved_tracefunc)
223 227
224 def test_simple_caller(self): 228 def test_simple_caller(self):
225 self.tracer.runfunc(traced_func_simple_caller, 1) 229 self.tracer.runfunc(traced_func_simple_caller, 1)
226 230
227 expected = { 231 expected = {
228 self.filemod + ('traced_func_simple_caller',): 1, 232 self.filemod + ('traced_func_simple_caller',): 1,
229 self.filemod + ('traced_func_linear',): 1, 233 self.filemod + ('traced_func_linear',): 1,
230 } 234 }
231 self.assertEqual(self.tracer.results().calledfuncs, expected) 235 self.assertEqual(self.tracer.results().calledfuncs, expected)
232 236
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 # Matched before. 353 # Matched before.
350 self.assertTrue(ignore.names(jn('bar', 'baz.py'), 'baz')) 354 self.assertTrue(ignore.names(jn('bar', 'baz.py'), 'baz'))
351 355
352 356
353 def test_main(): 357 def test_main():
354 run_unittest(__name__) 358 run_unittest(__name__)
355 359
356 360
357 if __name__ == '__main__': 361 if __name__ == '__main__':
358 test_main() 362 test_main()
OLDNEW
« no previous file with comments | « no previous file | Lib/trace.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+