From 9b603e707704102275d5521cc6c110f357e7ea96 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 23 Nov 2012 21:54:56 -0500 Subject: If a file is missing, don't show an error message with the wrong path. #60. --- test/test_html.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'test') 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 + ) -- cgit v1.2.1