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

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

Issue 16510: Using appropriate checks in tests
Patch Set: Created 5 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 | « Lib/test/test_traceback.py ('k') | Lib/test/test_types.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 io 2 import io
3 import sys 3 import sys
4 from test.support import (run_unittest, TESTFN, rmtree, unlink, 4 from test.support import (run_unittest, TESTFN, rmtree, unlink,
5 captured_stdout) 5 captured_stdout)
6 import unittest 6 import unittest
7 7
8 import trace 8 import trace
9 from trace import CoverageResults, Trace 9 from trace import CoverageResults, Trace
10 10
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 cmd='from test import test_pprint; test_pprint.test_main()'): 300 cmd='from test import test_pprint; test_pprint.test_main()'):
301 tracer.run(cmd) 301 tracer.run(cmd)
302 r = tracer.results() 302 r = tracer.results()
303 r.write_results(show_missing=True, summary=True, coverdir=TESTFN) 303 r.write_results(show_missing=True, summary=True, coverdir=TESTFN)
304 304
305 def test_coverage(self): 305 def test_coverage(self):
306 tracer = trace.Trace(trace=0, count=1) 306 tracer = trace.Trace(trace=0, count=1)
307 with captured_stdout() as stdout: 307 with captured_stdout() as stdout:
308 self._coverage(tracer) 308 self._coverage(tracer)
309 stdout = stdout.getvalue() 309 stdout = stdout.getvalue()
310 self.assertTrue("pprint.py" in stdout) 310 self.assertIn("pprint.py", stdout)
311 self.assertTrue("case.py" in stdout) # from unittest 311 self.assertIn("case.py", stdout) # from unittest
312 files = os.listdir(TESTFN) 312 files = os.listdir(TESTFN)
313 self.assertTrue("pprint.cover" in files) 313 self.assertIn("pprint.cover", files)
314 self.assertTrue("unittest.case.cover" in files) 314 self.assertIn("unittest.case.cover", files)
315 315
316 def test_coverage_ignore(self): 316 def test_coverage_ignore(self):
317 # Ignore all files, nothing should be traced nor printed 317 # Ignore all files, nothing should be traced nor printed
318 libpath = os.path.normpath(os.path.dirname(os.__file__)) 318 libpath = os.path.normpath(os.path.dirname(os.__file__))
319 # sys.prefix does not work when running from a checkout 319 # sys.prefix does not work when running from a checkout
320 tracer = trace.Trace(ignoredirs=[sys.base_prefix, sys.base_exec_prefix, 320 tracer = trace.Trace(ignoredirs=[sys.base_prefix, sys.base_exec_prefix,
321 libpath], trace=0, count=1) 321 libpath], trace=0, count=1)
322 with captured_stdout() as stdout: 322 with captured_stdout() as stdout:
323 self._coverage(tracer) 323 self._coverage(tracer)
324 if os.path.exists(TESTFN): 324 if os.path.exists(TESTFN):
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 with self.assertWarns(DeprecationWarning): 406 with self.assertWarns(DeprecationWarning):
407 trace.find_executable_linenos(fd.name) 407 trace.find_executable_linenos(fd.name)
408 408
409 409
410 def test_main(): 410 def test_main():
411 run_unittest(__name__) 411 run_unittest(__name__)
412 412
413 413
414 if __name__ == '__main__': 414 if __name__ == '__main__':
415 test_main() 415 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_traceback.py ('k') | Lib/test/test_types.py » ('j') | no next file with comments »

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