Back to index

python3.2  3.2.2
Public Member Functions | Private Member Functions
test.test_trace.TestCoverage Class Reference

List of all members.

Public Member Functions

def tearDown
def test_coverage
def test_coverage_ignore
def test_issue9936

Private Member Functions

def _coverage

Detailed Description

Definition at line 282 of file test_trace.py.


Member Function Documentation

def test.test_trace.TestCoverage._coverage (   self,
  tracer,
  cmd = 'from test import test_pprint; test_pprint.test_main()' 
) [private]

Definition at line 288 of file test_trace.py.

00288 
00289                   cmd='from test import test_pprint; test_pprint.test_main()'):
00290         tracer.run(cmd)
00291         r = tracer.results()
00292         r.write_results(show_missing=True, summary=True, coverdir=TESTFN)

Here is the caller graph for this function:

Definition at line 283 of file test_trace.py.

00283 
00284     def tearDown(self):
00285         rmtree(TESTFN)
00286         unlink(TESTFN)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 293 of file test_trace.py.

00293 
00294     def test_coverage(self):
00295         tracer = trace.Trace(trace=0, count=1)
00296         with captured_stdout() as stdout:
00297             self._coverage(tracer)
00298         stdout = stdout.getvalue()
00299         self.assertTrue("pprint.py" in stdout)
00300         self.assertTrue("case.py" in stdout)   # from unittest
00301         files = os.listdir(TESTFN)
00302         self.assertTrue("pprint.cover" in files)
00303         self.assertTrue("unittest.case.cover" in files)

Here is the call graph for this function:

Definition at line 304 of file test_trace.py.

00304 
00305     def test_coverage_ignore(self):
00306         # Ignore all files, nothing should be traced nor printed
00307         libpath = os.path.normpath(os.path.dirname(os.__file__))
00308         # sys.prefix does not work when running from a checkout
00309         tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix, libpath],
00310                              trace=0, count=1)
00311         with captured_stdout() as stdout:
00312             self._coverage(tracer)
00313         if os.path.exists(TESTFN):
00314             files = os.listdir(TESTFN)
00315             self.assertEqual(files, [])

Here is the call graph for this function:

Definition at line 316 of file test_trace.py.

00316 
00317     def test_issue9936(self):
00318         tracer = trace.Trace(trace=0, count=1)
00319         modname = 'test.tracedmodules.testmod'
00320         # Ensure that the module is executed in import
00321         if modname in sys.modules:
00322             del sys.modules[modname]
00323         cmd = ("import test.tracedmodules.testmod as t;"
00324                "t.func(0); t.func2();")
00325         with captured_stdout() as stdout:
00326             self._coverage(tracer, cmd)
00327         stdout.seek(0)
00328         stdout.readline()
00329         coverage = {}
00330         for line in stdout:
00331             lines, cov, module = line.split()[:3]
00332             coverage[module] = (int(lines), int(cov[:-1]))
00333         # XXX This is needed to run regrtest.py as a script
00334         modname = trace._fullmodname(sys.modules[modname].__file__)
00335         self.assertIn(modname, coverage)
00336         self.assertEqual(coverage[modname], (5, 100))

Here is the call graph for this function:


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