diff options
-rw-r--r-- | coverage/control.py | 6 | ||||
-rw-r--r-- | coverage/python.py | 6 | ||||
-rw-r--r-- | tests/test_codeunit.py | 36 |
3 files changed, 25 insertions, 23 deletions
diff --git a/coverage/control.py b/coverage/control.py index a0c21a4a..2db58021 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -24,7 +24,7 @@ from coverage.misc import CoverageException, bool_or_none, join_regex from coverage.misc import file_be_gone, overrides from coverage.monkey import patch_multiprocessing from coverage.plugin import CoveragePlugin, FileReporter -from coverage.python import PythonCodeUnit +from coverage.python import PythonFileReporter from coverage.results import Analysis, Numbers from coverage.summary import SummaryReporter from coverage.xmlreport import XmlReporter @@ -343,7 +343,7 @@ class Coverage(object): def _canonical_dir(self, morf): """Return the canonical directory of the module or file `morf`.""" - morf_filename = PythonCodeUnit(morf, self).filename + morf_filename = PythonFileReporter(morf, self).filename return os.path.split(morf_filename)[0] def _source_for_file(self, filename): @@ -850,7 +850,7 @@ class Coverage(object): ) ) else: - file_reporter = PythonCodeUnit(morf, self) + file_reporter = PythonFileReporter(morf, self) return file_reporter diff --git a/coverage/python.py b/coverage/python.py index 7a9b842a..19212a5b 100644 --- a/coverage/python.py +++ b/coverage/python.py @@ -87,7 +87,7 @@ def get_zip_bytes(filename): return None -class PythonCodeUnit(FileReporter): +class PythonFileReporter(FileReporter): """Report support for a Python file.""" def __init__(self, morf, coverage=None): @@ -105,7 +105,9 @@ class PythonCodeUnit(FileReporter): elif filename.endswith('$py.class'): # Jython filename = filename[:-9] + ".py" - super(PythonCodeUnit, self).__init__(file_locator.canonical_filename(filename)) + super(PythonFileReporter, self).__init__( + file_locator.canonical_filename(filename) + ) if hasattr(morf, '__name__'): name = morf.__name__ diff --git a/tests/test_codeunit.py b/tests/test_codeunit.py index 3b873cd7..473bfe49 100644 --- a/tests/test_codeunit.py +++ b/tests/test_codeunit.py @@ -4,7 +4,7 @@ import os import sys from coverage.plugin import FileReporter -from coverage.python import PythonCodeUnit +from coverage.python import PythonFileReporter from tests.coveragetest import CoverageTest @@ -17,21 +17,21 @@ def native(filename): return filename.replace("/", os.sep) -class CodeUnitTest(CoverageTest): - """Tests for coverage.codeunit""" +class FileReporterTest(CoverageTest): + """Tests for FileReporter classes.""" run_in_temp_dir = False def setUp(self): - super(CodeUnitTest, self).setUp() + super(FileReporterTest, self).setUp() # Parent class saves and restores sys.path, we can just modify it. testmods = self.nice_file(os.path.dirname(__file__), 'modules') sys.path.append(testmods) def test_filenames(self): - acu = PythonCodeUnit("aa/afile.py") - bcu = PythonCodeUnit("aa/bb/bfile.py") - ccu = PythonCodeUnit("aa/bb/cc/cfile.py") + acu = PythonFileReporter("aa/afile.py") + bcu = PythonFileReporter("aa/bb/bfile.py") + ccu = PythonFileReporter("aa/bb/cc/cfile.py") self.assertEqual(acu.name, "aa/afile.py") self.assertEqual(bcu.name, "aa/bb/bfile.py") self.assertEqual(ccu.name, "aa/bb/cc/cfile.py") @@ -43,9 +43,9 @@ class CodeUnitTest(CoverageTest): self.assertEqual(ccu.source(), "# cfile.py\n") def test_odd_filenames(self): - acu = PythonCodeUnit("aa/afile.odd.py") - bcu = PythonCodeUnit("aa/bb/bfile.odd.py") - b2cu = PythonCodeUnit("aa/bb.odd/bfile.py") + acu = PythonFileReporter("aa/afile.odd.py") + bcu = PythonFileReporter("aa/bb/bfile.odd.py") + b2cu = PythonFileReporter("aa/bb.odd/bfile.py") self.assertEqual(acu.name, "aa/afile.odd.py") self.assertEqual(bcu.name, "aa/bb/bfile.odd.py") self.assertEqual(b2cu.name, "aa/bb.odd/bfile.py") @@ -61,9 +61,9 @@ class CodeUnitTest(CoverageTest): import aa.bb import aa.bb.cc - acu = PythonCodeUnit(aa) - bcu = PythonCodeUnit(aa.bb) - ccu = PythonCodeUnit(aa.bb.cc) + acu = PythonFileReporter(aa) + bcu = PythonFileReporter(aa.bb) + ccu = PythonFileReporter(aa.bb.cc) self.assertEqual(acu.name, native("aa.py")) self.assertEqual(bcu.name, native("aa/bb.py")) self.assertEqual(ccu.name, native("aa/bb/cc.py")) @@ -79,9 +79,9 @@ class CodeUnitTest(CoverageTest): import aa.bb.bfile import aa.bb.cc.cfile - acu = PythonCodeUnit(aa.afile) - bcu = PythonCodeUnit(aa.bb.bfile) - ccu = PythonCodeUnit(aa.bb.cc.cfile) + acu = PythonFileReporter(aa.afile) + bcu = PythonFileReporter(aa.bb.bfile) + ccu = PythonFileReporter(aa.bb.cc.cfile) self.assertEqual(acu.name, native("aa/afile.py")) self.assertEqual(bcu.name, native("aa/bb/bfile.py")) self.assertEqual(ccu.name, native("aa/bb/cc/cfile.py")) @@ -114,7 +114,7 @@ class CodeUnitTest(CoverageTest): # in the path is actually the .egg zip file. self.assert_doesnt_exist(egg1.__file__) - ecu = PythonCodeUnit(egg1) - eecu = PythonCodeUnit(egg1.egg1) + ecu = PythonFileReporter(egg1) + eecu = PythonFileReporter(egg1.egg1) self.assertEqual(ecu.source(), u"") self.assertEqual(eecu.source().split("\n")[0], u"# My egg file!") |