summaryrefslogtreecommitdiff
path: root/tests/test_html.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2013-09-28 21:31:37 -0400
committerNed Batchelder <ned@nedbatchelder.com>2013-09-28 21:31:37 -0400
commit765993ad586e0e2f17dca0536e25d157acf6fcd1 (patch)
treeba44803cec4c03d3f4ef70af31ebb4166bcbe8c6 /tests/test_html.py
parentb33c041b055f0bc243790d6cce4bb32689f3b4f3 (diff)
downloadpython-coveragepy-git-765993ad586e0e2f17dca0536e25d157acf6fcd1.tar.gz
Search a list of places to find HTML report static files. #259.
--HG-- rename : coverage/htmlfiles/jquery-1.4.3.min.js => coverage/htmlfiles/jquery.min.js
Diffstat (limited to 'tests/test_html.py')
-rw-r--r--tests/test_html.py41
1 files changed, 39 insertions, 2 deletions
diff --git a/tests/test_html.py b/tests/test_html.py
index e44db970..e1d41d93 100644
--- a/tests/test_html.py
+++ b/tests/test_html.py
@@ -3,7 +3,8 @@
import os.path, re, sys
import coverage
-from coverage.misc import NotPython, NoSource
+import coverage.html
+from coverage.misc import CoverageException, NotPython, NoSource
from tests.coveragetest import CoverageTest
@@ -290,7 +291,43 @@ class HtmlTest(CoverageTest):
missing_file = os.path.join(self.temp_dir, "sub", "another.py")
missing_file = os.path.realpath(missing_file)
- self.assertRaisesRegexp(NoSource,
+ self.assertRaisesRegexp(
+ NoSource,
"(?i)No source for code: '%s'" % re.escape(missing_file),
cov.html_report
)
+
+class HtmlStaticFileTest(CoverageTest):
+ """Tests of the static file copying for the HTML report."""
+
+ def setUp(self):
+ super(HtmlStaticFileTest, self).setUp()
+ self.original_path = list(coverage.html.STATIC_PATH)
+
+ def tearDown(self):
+ coverage.html.STATIC_PATH = self.original_path
+ super(HtmlStaticFileTest, self).tearDown()
+
+ def test_copying_static_files_from_system(self):
+ # Make a new place for static files.
+ self.make_file("static_here/jquery.min.js", "Not Really JQuery!")
+ coverage.html.STATIC_PATH.insert(0, "static_here")
+
+ self.make_file("main.py", "print(17)")
+ cov = coverage.coverage()
+ self.start_import_stop(cov, "main")
+ cov.html_report()
+ jquery = open("htmlcov/jquery.min.js").read()
+ self.assertEqual(jquery, "Not Really JQuery!")
+
+ def test_cant_find_static_files(self):
+ # Make the path point to useless places.
+ coverage.html.STATIC_PATH = ["/xyzzy"]
+
+ self.make_file("main.py", "print(17)")
+ cov = coverage.coverage()
+ self.start_import_stop(cov, "main")
+ self.assertRaisesRegexp(
+ CoverageException, "Couldn't find static file '.*'",
+ cov.html_report
+ )