diff options
| author | Ned Batchelder <ned@nedbatchelder.com> | 2011-08-08 20:37:38 -0400 |
|---|---|---|
| committer | Ned Batchelder <ned@nedbatchelder.com> | 2011-08-08 20:37:38 -0400 |
| commit | 1966f545699490822117d66a86f2de91734a6ee9 (patch) | |
| tree | 7b052bb6f115e455b7d7f21f01dd843c56c296db /test | |
| parent | ced439588b3b3a66d5e68f00e8542d56250844d3 (diff) | |
| download | python-coveragepy-1966f545699490822117d66a86f2de91734a6ee9.tar.gz | |
A fullcoverage tracer that works. Events are stashed, then replayed when coverage is started.
Diffstat (limited to 'test')
| -rw-r--r-- | test/coveragetest.py | 2 | ||||
| -rw-r--r-- | test/test_process.py | 20 |
2 files changed, 21 insertions, 1 deletions
diff --git a/test/coveragetest.py b/test/coveragetest.py index 3242e52..9bff27e 100644 --- a/test/coveragetest.py +++ b/test/coveragetest.py @@ -426,7 +426,7 @@ class CoverageTest(TestCase): here = os.path.dirname(self.nice_file(coverage.__file__, "..")) testmods = self.nice_file(here, 'test/modules') zipfile = self.nice_file(here, 'test/zipmods.zip') - pypath = self.original_environ('PYTHONPATH', "") + pypath = os.getenv('PYTHONPATH') if pypath: pypath += os.pathsep pypath += testmods + os.pathsep + zipfile diff --git a/test/test_process.py b/test/test_process.py index c32868b..e62fce2 100644 --- a/test/test_process.py +++ b/test/test_process.py @@ -292,3 +292,23 @@ class ProcessTest(CoverageTest): self.assertTrue("No module named no_such_module" in out) self.assertTrue("warning" not in out) + if sys.version_info >= (2, 7): # Need coverage runnable as a module. + def test_fullcoverage(self): + # fullcoverage is a trick to get stdlib modules measured from the + # very beginning of the process. Here we import os and then check + # how many lines are measured. + self.make_file("getenv.py", """\ + import os + print("FOOEY == %s" % os.getenv("FOOEY")) + """) + + fullcov = os.path.join(os.path.dirname(coverage.__file__), "fullcoverage") + self.set_environ("FOOEY", "BOO") + self.set_environ("PYTHONPATH", fullcov) + out = self.run_command("python -m coverage run -L getenv.py") + self.assertEqual(out, "FOOEY == BOO\n") + data = coverage.CoverageData() + data.read_file(".coverage") + # The actual number of lines in os.py executed when it is imported + # is 120 or so. Just running os.getenv executes about 5. + self.assertGreater(data.summary()['os.py'], 50) |
