summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.txt10
-rw-r--r--coverage/data.py4
-rw-r--r--tests/test_data.py23
-rw-r--r--tests/test_html.py9
4 files changed, 44 insertions, 2 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index b464d6b8..c5b20c3a 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -6,6 +6,16 @@ Change history for Coverage.py
==============================
+Latest
+------
+
+- Reporting on an unmeasured file would fail with a traceback. This is now
+ fixed, closing `issue 403`_.
+
+.. _issue 403: https://bitbucket.org/ned/coveragepy/issues/403/hasherupdate-fails-with-typeerror-nonetype
+
+
+
Version 4.0b2 --- 22 August 2015
--------------------------------
diff --git a/coverage/data.py b/coverage/data.py
index 41883398..c608f489 100644
--- a/coverage/data.py
+++ b/coverage/data.py
@@ -580,9 +580,9 @@ class CoverageData(object):
"""
if self._has_arcs():
- hasher.update(sorted(self.arcs(filename)))
+ hasher.update(sorted(self.arcs(filename) or []))
else:
- hasher.update(sorted(self.lines(filename)))
+ hasher.update(sorted(self.lines(filename) or []))
hasher.update(self.file_tracer(filename))
##
diff --git a/tests/test_data.py b/tests/test_data.py
index 93e482d7..b3882726 100644
--- a/tests/test_data.py
+++ b/tests/test_data.py
@@ -381,6 +381,29 @@ class CoverageDataTest(DataTestHelpers, CoverageTest):
mock.call.update("hologram_plugin"), # file_tracer name
])
+ def test_add_to_lines_hash_with_missing_file(self):
+ # https://bitbucket.org/ned/coveragepy/issues/403
+ covdata = CoverageData()
+ covdata.add_lines(LINES_1)
+ hasher = mock.Mock()
+ covdata.add_to_hash("missing.py", hasher)
+ self.assertEqual(hasher.method_calls, [
+ mock.call.update([]),
+ mock.call.update(None),
+ ])
+
+ def test_add_to_arcs_hash_with_missing_file(self):
+ # https://bitbucket.org/ned/coveragepy/issues/403
+ covdata = CoverageData()
+ covdata.add_arcs(ARCS_3)
+ covdata.add_file_tracers({"y.py": "hologram_plugin"})
+ hasher = mock.Mock()
+ covdata.add_to_hash("missing.py", hasher)
+ self.assertEqual(hasher.method_calls, [
+ mock.call.update([]),
+ mock.call.update(None),
+ ])
+
def test_empty_lines_are_still_lines(self):
covdata = CoverageData()
covdata.add_lines({})
diff --git a/tests/test_html.py b/tests/test_html.py
index 3f14bbf5..a852cbe9 100644
--- a/tests/test_html.py
+++ b/tests/test_html.py
@@ -388,6 +388,15 @@ class HtmlTest(HtmlTestHelpers, CoverageTest):
with open("htmlcov/main_file_py.html") as f:
self.assert_correct_timestamp(f.read())
+ def test_reporting_on_unmeasured_file(self):
+ # It should be ok to ask for an HTML report on a file that wasn't even
+ # measured at all. https://bitbucket.org/ned/coveragepy/issues/403
+ self.create_initial_files()
+ self.make_file("other.py", "a = 1\n")
+ self.run_coverage(htmlargs=dict(morfs=['other.py']))
+ self.assert_exists("htmlcov/index.html")
+ self.assert_exists("htmlcov/other_py.html")
+
class HtmlStaticFileTest(CoverageTest):
"""Tests of the static file copying for the HTML report."""