summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2012-11-23 21:54:56 -0500
committerNed Batchelder <ned@nedbatchelder.com>2012-11-23 21:54:56 -0500
commit9b603e707704102275d5521cc6c110f357e7ea96 (patch)
tree81116da37539a0ccb471f35cb8f31eedd8dac005 /test
parentb18119c4949b4a4750a52ea8835e64f520b08c8a (diff)
downloadpython-coveragepy-9b603e707704102275d5521cc6c110f357e7ea96.tar.gz
If a file is missing, don't show an error message with the wrong path. #60.
Diffstat (limited to 'test')
-rw-r--r--test/test_html.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/test/test_html.py b/test/test_html.py
index 2910656..2f1dc5d 100644
--- a/test/test_html.py
+++ b/test/test_html.py
@@ -3,7 +3,7 @@
import os.path, sys
import coverage
-from coverage.misc import NotPython
+from coverage.misc import NotPython, NoSource
sys.path.insert(0, os.path.split(__file__)[0]) # Force relative import for Py3k
from coveragetest import CoverageTest
@@ -287,3 +287,24 @@ class HtmlWithUnparsableFilesTest(CoverageTest):
cov.stop()
cov.html_report()
self.assert_exists("htmlcov/index.html")
+
+
+class HtmlTest(CoverageTest):
+ """Moar HTML tests."""
+
+ def test_missing_source_file_incorrect_message(self):
+ # https://bitbucket.org/ned/coveragepy/issue/60
+ self.make_file("thefile.py", "import sub.another\n")
+ self.make_file("sub/__init__.py", "")
+ self.make_file("sub/another.py", "print('another')\n")
+ cov = coverage.coverage()
+ cov.start()
+ self.import_local_file('thefile')
+ cov.stop()
+ os.remove("sub/another.py")
+
+ missing_file = os.path.join(self.temp_dir, "sub", "another.py")
+ self.assertRaisesRegexp(NoSource,
+ "No source for code: '%s'" % missing_file,
+ cov.html_report
+ )