summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coverage/control.py3
-rw-r--r--coverage/data.py5
-rw-r--r--tests/test_data.py14
3 files changed, 20 insertions, 2 deletions
diff --git a/coverage/control.py b/coverage/control.py
index ca3660ac..7c14e1b0 100644
--- a/coverage/control.py
+++ b/coverage/control.py
@@ -772,8 +772,7 @@ class Coverage(object):
)
# Find out if we got any data.
- summary = self.data.summary()
- if not summary and self._warn_no_data:
+ if not self.data and self._warn_no_data:
self._warn("No data was collected.")
# Find files that were never executed at all.
diff --git a/coverage/data.py b/coverage/data.py
index 7b9dd7ea..c9e9a036 100644
--- a/coverage/data.py
+++ b/coverage/data.py
@@ -230,6 +230,11 @@ class CoverageData(object):
summ[filename_fn(filename)] = len(lines)
return summ
+ def __nonzero__(self):
+ return bool(self._lines) or bool(self._arcs)
+
+ __bool__ = __nonzero__
+
def has_arcs(self):
"""Does this data have arcs?"""
return bool(self._arcs)
diff --git a/tests/test_data.py b/tests/test_data.py
index b78e21eb..15d49c00 100644
--- a/tests/test_data.py
+++ b/tests/test_data.py
@@ -64,6 +64,20 @@ class DataTest(DataTestHelpers, CoverageTest):
run_in_temp_dir = False
+ def test_empty_data_is_false(self):
+ covdata = CoverageData()
+ self.assertFalse(covdata)
+
+ def test_line_data_is_true(self):
+ covdata = CoverageData()
+ covdata.add_lines(DATA_1)
+ self.assertTrue(covdata)
+
+ def test_arc_data_is_true(self):
+ covdata = CoverageData()
+ covdata.add_arcs(ARC_DATA_3)
+ self.assertTrue(covdata)
+
def test_reading_empty(self):
# Make sure there is no .coverage data file here.
if os.path.exists(".coverage"):