diff options
-rw-r--r-- | coverage/cmdline.py | 2 | ||||
-rw-r--r-- | coverage/data.py | 9 | ||||
-rw-r--r-- | tests/test_api.py | 2 | ||||
-rw-r--r-- | tests/test_cmdline.py | 14 | ||||
-rw-r--r-- | tests/test_concurrency.py | 2 | ||||
-rw-r--r-- | tests/test_data.py | 22 | ||||
-rw-r--r-- | tests/test_plugins.py | 8 | ||||
-rw-r--r-- | tests/test_process.py | 16 |
8 files changed, 40 insertions, 35 deletions
diff --git a/coverage/cmdline.py b/coverage/cmdline.py index 0620c8ee..1a8a0268 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -589,7 +589,7 @@ class CoverageScript(object): print(info_header("data")) print("path: %s" % self.coverage.data.filename) print("has_arcs: %r" % self.coverage.data.has_arcs()) - summary = self.coverage.data.summary(fullpath=True) + summary = self.coverage.data.line_counts(fullpath=True) if summary: plugins = self.coverage.data.plugin_data() filenames = sorted(summary.keys()) diff --git a/coverage/data.py b/coverage/data.py index c9e9a036..0f9a4cfd 100644 --- a/coverage/data.py +++ b/coverage/data.py @@ -213,13 +213,18 @@ class CoverageData(object): hasher.update(self.lines(filename)) hasher.update(self.arcs(filename)) - def summary(self, fullpath=False): - """Return a dict summarizing the coverage data. + def line_counts(self, fullpath=False): + """Return a dict summarizing the line coverage data. Keys are based on the filenames, and values are the number of executed lines. If `fullpath` is true, then the keys are the full pathnames of the files, otherwise they are the basenames of the files. + This is used for testing, not for actual use in the product. + + Returns: + dict mapping filenames to counts of lines. + """ summ = {} if fullpath: diff --git a/tests/test_api.py b/tests/test_api.py index b4ae7482..ef34e843 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -379,7 +379,7 @@ class SourceOmitIncludeTest(OmitIncludeTestsMixin, CoverageTest): import usepkgs # pragma: nested # pylint: disable=import-error,unused-variable cov.stop() # pragma: nested data = cov.get_data() - summary = data.summary() + summary = data.line_counts() for k, v in list(summary.items()): assert k.endswith(".py") summary[k[:-3]] = v diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py index b616ed51..d73e413e 100644 --- a/tests/test_cmdline.py +++ b/tests/test_cmdline.py @@ -141,8 +141,8 @@ class BaseCmdLineTestTest(BaseCmdLineTest): class FakeCoverageForDebugData(object): """Just enough of a fake coverage package for the 'debug data' tests.""" - def __init__(self, summary, plugin_data=None): - self._summary = summary + def __init__(self, line_counts, plugin_data=None): + self._line_counts = line_counts self._plugin_data = plugin_data or {} self.filename = "FILENAME" self.data = self @@ -162,9 +162,9 @@ class FakeCoverageForDebugData(object): """Fake coverage().data.has_arcs()""" return False - def summary(self, fullpath): # pylint: disable=unused-argument - """Fake coverage().data.summary()""" - return self._summary + def line_counts(self, fullpath): # pylint: disable=unused-argument + """Fake coverage().data.line_counts()""" + return self._line_counts def plugin_data(self): """Fake coverage().data.plugin_data()""" @@ -234,7 +234,7 @@ class CmdLineTest(BaseCmdLineTest): def test_debug_data(self): fake = FakeCoverageForDebugData( - summary={ + line_counts={ 'file1.py': 17, 'file2.py': 23, }, plugin_data={ @@ -253,7 +253,7 @@ class CmdLineTest(BaseCmdLineTest): """)) def test_debug_data_with_no_data(self): - fake = FakeCoverageForDebugData(summary={}) + fake = FakeCoverageForDebugData(line_counts={}) self.command_line("debug data", _covpkg=fake) self.assertMultiLineEqual(self.stdout(), textwrap.dedent("""\ -- data ------------------------------------------------------ diff --git a/tests/test_concurrency.py b/tests/test_concurrency.py index e0eacd18..e2ea3aa9 100644 --- a/tests/test_concurrency.py +++ b/tests/test_concurrency.py @@ -154,7 +154,7 @@ class ConcurrencyTest(CoverageTest): print_simple_annotation(code, linenos) lines = line_count(code) - self.assertEqual(data.summary()['try_it.py'], lines) + self.assertEqual(data.line_counts()['try_it.py'], lines) else: expected_out = ( "Can't support concurrency=%s with PyTracer, " diff --git a/tests/test_data.py b/tests/test_data.py index 15d49c00..de178a00 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -50,9 +50,9 @@ class DataTestHelpers(CoverageTest): self.data_files = CoverageDataFiles() super(DataTestHelpers, self).setUp() - def assert_summary(self, covdata, summary, fullpath=False): - """Check that the summary of `covdata` is `summary`.""" - self.assertEqual(covdata.summary(fullpath), summary) + def assert_line_counts(self, covdata, line_counts, fullpath=False): + """Check that the line_counts of `covdata` is `line_counts`.""" + self.assertEqual(covdata.line_counts(fullpath), line_counts) def assert_measured_files(self, covdata, measured): """Check that `covdata`'s measured files are `measured`.""" @@ -84,12 +84,12 @@ class DataTest(DataTestHelpers, CoverageTest): os.remove(".coverage") covdata = CoverageData() self.data_files.read(covdata) - self.assert_summary(covdata, {}) + self.assert_line_counts(covdata, {}) def test_adding_data(self): covdata = CoverageData() covdata.add_lines(DATA_1) - self.assert_summary(covdata, SUMMARY_1) + self.assert_line_counts(covdata, SUMMARY_1) self.assert_measured_files(covdata, MEASURED_FILES_1) def test_touch_file(self): @@ -105,7 +105,7 @@ class DataTest(DataTestHelpers, CoverageTest): covdata2 = CoverageData() self.data_files.read(covdata2) - self.assert_summary(covdata2, SUMMARY_1) + self.assert_line_counts(covdata2, SUMMARY_1) def test_combining(self): covdata1 = CoverageData() @@ -118,7 +118,7 @@ class DataTest(DataTestHelpers, CoverageTest): covdata3 = CoverageData() self.data_files.combine_parallel_data(covdata3) - self.assert_summary(covdata3, SUMMARY_1_2) + self.assert_line_counts(covdata3, SUMMARY_1_2) self.assert_measured_files(covdata3, MEASURED_FILES_1_2) def test_erasing(self): @@ -127,12 +127,12 @@ class DataTest(DataTestHelpers, CoverageTest): self.data_files.write(covdata1) covdata1.erase() - self.assert_summary(covdata1, {}) + self.assert_line_counts(covdata1, {}) self.data_files.erase() covdata2 = CoverageData() self.data_files.read(covdata2) - self.assert_summary(covdata2, {}) + self.assert_line_counts(covdata2, {}) def test_file_format(self): # Write with CoverageData, then read the pickle explicitly. @@ -188,7 +188,7 @@ class DataTest(DataTestHelpers, CoverageTest): apy = canonical_filename('./a.py') sub_bpy = canonical_filename('./sub/b.py') - self.assert_summary(covdata3, {apy: 4, sub_bpy: 2}, fullpath=True) + self.assert_line_counts(covdata3, {apy: 4, sub_bpy: 2}, fullpath=True) self.assert_measured_files(covdata3, [apy, sub_bpy]) @@ -214,5 +214,5 @@ class DataTestInTempDir(DataTestHelpers, CoverageTest): 'cov2/', ]) - self.assert_summary(covdata3, SUMMARY_1_2) + self.assert_line_counts(covdata3, SUMMARY_1_2) self.assert_measured_files(covdata3, MEASURED_FILES_1_2) diff --git a/tests/test_plugins.py b/tests/test_plugins.py index 2f58eceb..26649a39 100644 --- a/tests/test_plugins.py +++ b/tests/test_plugins.py @@ -366,20 +366,20 @@ class GoodPluginTest(FileTracerTest): _, statements, missing, _ = cov.analysis("foo_7.html") self.assertEqual(statements, [1, 2, 3, 4, 5, 6, 7]) self.assertEqual(missing, [1, 2, 3, 6, 7]) - self.assertIn("foo_7.html", cov.data.summary()) + self.assertIn("foo_7.html", cov.data.line_counts()) _, statements, missing, _ = cov.analysis("bar_4.html") self.assertEqual(statements, [1, 2, 3, 4]) self.assertEqual(missing, [1, 4]) - self.assertIn("bar_4.html", cov.data.summary()) + self.assertIn("bar_4.html", cov.data.line_counts()) - self.assertNotIn("quux_5.html", cov.data.summary()) + self.assertNotIn("quux_5.html", cov.data.line_counts()) if env.PY2: _, statements, missing, _ = cov.analysis("uni_3.html") self.assertEqual(statements, [1, 2, 3]) self.assertEqual(missing, [1]) - self.assertIn("uni_3.html", cov.data.summary()) + self.assertIn("uni_3.html", cov.data.line_counts()) def test_plugin2_with_branch(self): self.make_render_and_caller() diff --git a/tests/test_process.py b/tests/test_process.py index 78fba81a..f7946b6a 100644 --- a/tests/test_process.py +++ b/tests/test_process.py @@ -83,7 +83,7 @@ class ProcessTest(CoverageTest): # executed. data = coverage.CoverageData() data.read_file(".coverage") - self.assertEqual(data.summary()['b_or_c.py'], 7) + self.assertEqual(data.line_counts()['b_or_c.py'], 7) def test_combine_parallel_data_in_two_steps(self): self.make_file("b_or_c.py", """\ @@ -123,7 +123,7 @@ class ProcessTest(CoverageTest): # executed. data = coverage.CoverageData() data.read_file(".coverage") - self.assertEqual(data.summary()['b_or_c.py'], 7) + self.assertEqual(data.line_counts()['b_or_c.py'], 7) def test_combine_with_rc(self): self.make_file("b_or_c.py", """\ @@ -165,7 +165,7 @@ class ProcessTest(CoverageTest): # executed. data = coverage.CoverageData() data.read_file(".coverage") - self.assertEqual(data.summary()['b_or_c.py'], 7) + self.assertEqual(data.line_counts()['b_or_c.py'], 7) # Reporting should still work even with the .rc file out = self.run_command("coverage report") @@ -219,7 +219,7 @@ class ProcessTest(CoverageTest): # files have been combined together. data = coverage.CoverageData() data.read_file(".coverage") - summary = data.summary(fullpath=True) + summary = data.line_counts(fullpath=True) self.assertEqual(len(summary), 1) actual = os.path.normcase(os.path.abspath(list(summary.keys())[0])) expected = os.path.normcase(os.path.abspath('src/x.py')) @@ -447,7 +447,7 @@ class ProcessTest(CoverageTest): # executed. data = coverage.CoverageData() data.read_file(".coverage") - self.assertEqual(data.summary()['fork.py'], 9) + self.assertEqual(data.line_counts()['fork.py'], 9) def test_warnings(self): self.make_file("hello.py", """\ @@ -558,7 +558,7 @@ class ProcessTest(CoverageTest): # The actual number of executed lines in os.py when it's # imported is 120 or so. Just running os.getenv executes # about 5. - self.assertGreater(data.summary()['os.py'], 50) + self.assertGreater(data.line_counts()['os.py'], 50) def test_deprecation_warnings(self): # Test that coverage doesn't trigger deprecation warnings. @@ -820,7 +820,7 @@ class ProcessStartupTest(ProcessCoverageMixin, CoverageTest): self.assert_exists(".mycovdata") data = coverage.CoverageData() data.read_file(".mycovdata") - self.assertEqual(data.summary()['sub.py'], 2) + self.assertEqual(data.line_counts()['sub.py'], 2) class ProcessStartupWithSourceTest(ProcessCoverageMixin, CoverageTest): @@ -902,7 +902,7 @@ class ProcessStartupWithSourceTest(ProcessCoverageMixin, CoverageTest): self.assert_exists(".coverage") data = coverage.CoverageData() data.read_file(".coverage") - summary = data.summary() + summary = data.line_counts() print(summary) self.assertEqual(summary[source + '.py'], 2) self.assertEqual(len(summary), 1) |