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

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

Issue 16510: Using appropriate checks in tests
Patch Set: Created 7 years, 2 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_tuple.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
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 cmd='from test import test_pprint; test_pprint.test_main()'): 299 cmd='from test import test_pprint; test_pprint.test_main()'):
300 tracer.run(cmd) 300 tracer.run(cmd)
301 r = tracer.results() 301 r = tracer.results()
302 r.write_results(show_missing=True, summary=True, coverdir=TESTFN) 302 r.write_results(show_missing=True, summary=True, coverdir=TESTFN)
303 303
304 def test_coverage(self): 304 def test_coverage(self):
305 tracer = trace.Trace(trace=0, count=1) 305 tracer = trace.Trace(trace=0, count=1)
306 with captured_stdout() as stdout: 306 with captured_stdout() as stdout:
307 self._coverage(tracer) 307 self._coverage(tracer)
308 stdout = stdout.getvalue() 308 stdout = stdout.getvalue()
309 self.assertTrue("pprint.py" in stdout) 309 self.assertIn("pprint.py", stdout)
310 self.assertTrue("case.py" in stdout) # from unittest 310 self.assertIn("case.py", stdout) # from unittest
311 files = os.listdir(TESTFN) 311 files = os.listdir(TESTFN)
312 self.assertTrue("pprint.cover" in files) 312 self.assertIn("pprint.cover", files)
313 self.assertTrue("unittest.case.cover" in files) 313 self.assertIn("unittest.case.cover", files)
314 314
315 def test_coverage_ignore(self): 315 def test_coverage_ignore(self):
316 # Ignore all files, nothing should be traced nor printed 316 # Ignore all files, nothing should be traced nor printed
317 libpath = os.path.normpath(os.path.dirname(os.__file__)) 317 libpath = os.path.normpath(os.path.dirname(os.__file__))
318 # sys.prefix does not work when running from a checkout 318 # sys.prefix does not work when running from a checkout
319 tracer = trace.Trace(ignoredirs=[sys.base_prefix, sys.base_exec_prefix, 319 tracer = trace.Trace(ignoredirs=[sys.base_prefix, sys.base_exec_prefix,
320 libpath], trace=0, count=1) 320 libpath], trace=0, count=1)
321 with captured_stdout() as stdout: 321 with captured_stdout() as stdout:
322 self._coverage(tracer) 322 self._coverage(tracer)
323 if os.path.exists(TESTFN): 323 if os.path.exists(TESTFN):
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 # Matched before. 360 # Matched before.
361 self.assertTrue(ignore.names(jn('bar', 'baz.py'), 'baz')) 361 self.assertTrue(ignore.names(jn('bar', 'baz.py'), 'baz'))
362 362
363 363
364 def test_main(): 364 def test_main():
365 run_unittest(__name__) 365 run_unittest(__name__)
366 366
367 367
368 if __name__ == '__main__': 368 if __name__ == '__main__':
369 test_main() 369 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_traceback.py ('k') | Lib/test/test_tuple.py » ('j') | no next file with comments »

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