summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coverage/html.py4
-rw-r--r--coverage/htmlfiles/index.html1
-rw-r--r--tests/test_html.py11
3 files changed, 15 insertions, 1 deletions
diff --git a/coverage/html.py b/coverage/html.py
index 2a9e0d11..92ca3f1e 100644
--- a/coverage/html.py
+++ b/coverage/html.py
@@ -2,6 +2,7 @@
from __future__ import unicode_literals
+import datetime
import json
import os
import re
@@ -261,11 +262,14 @@ class HtmlReporter(Reporter):
self.totals = sum(f['nums'] for f in self.files)
+ time_stamp = datetime.datetime.now().strftime('%Y-%m-%d %H:%M')
+
html = index_tmpl.render({
'arcs': self.arcs,
'extra_css': self.extra_css,
'files': self.files,
'totals': self.totals,
+ 'time_stamp': time_stamp,
})
self.write_html(
diff --git a/coverage/htmlfiles/index.html b/coverage/htmlfiles/index.html
index 90802c81..7f3ab3ef 100644
--- a/coverage/htmlfiles/index.html
+++ b/coverage/htmlfiles/index.html
@@ -23,6 +23,7 @@
<h1>{{ title|escape }}:
<span class='pc_cov'>{{totals.pc_covered_str}}%</span>
</h1>
+ <p>Created on {{ time_stamp }}</p>
<img id='keyboard_icon' src='keybd_closed.png' alt='Show keyboard shortcuts' />
diff --git a/tests/test_html.py b/tests/test_html.py
index 6b398c43..d9a6470d 100644
--- a/tests/test_html.py
+++ b/tests/test_html.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
"""Tests that HTML generation is awesome."""
+import datetime
import os.path
import re
@@ -323,7 +324,7 @@ class HtmlWithUnparsableFilesTest(HtmlTestHelpers, CoverageTest):
self.assertIn(expected, html_report)
-class HtmlTest(CoverageTest):
+class HtmlTest(HtmlTestHelpers, CoverageTest):
"""Moar HTML tests."""
def test_missing_source_file_incorrect_message(self):
@@ -353,6 +354,14 @@ class HtmlTest(CoverageTest):
self.assert_exists("htmlcov/afile.html")
self.assert_exists("htmlcov/afile_py.html")
+ def test_has_date_stamp_in_index(self):
+ self.create_initial_files()
+ self.run_coverage()
+ with open("htmlcov/index.html") as f:
+ index = f.read()
+ time_stamp = datetime.datetime.now().strftime('%Y-%m-%d %H:%M')
+ self.assertIn("<p>Created on {}</p>".format(time_stamp), index)
+
class HtmlStaticFileTest(CoverageTest):
"""Tests of the static file copying for the HTML report."""