summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2015-04-21 21:31:58 -0400
committerNed Batchelder <ned@nedbatchelder.com>2015-04-21 21:31:58 -0400
commit2a7a4f2161d26eeb898f3deec3f7ce21b0f2f957 (patch)
tree6ae60d1198cc845a239a9635acc5ecd6a5af744d
parent71e2e22f6d7601218f08ed038689fe8abc871d17 (diff)
downloadpython-coveragepy-2a7a4f2161d26eeb898f3deec3f7ce21b0f2f957.tar.gz
More work on #299
Add the timestamp to the Python output files also. Move the timestamp to the footer. Add Conrad to AUTHORS, and update the CHANGES file.
-rw-r--r--AUTHORS.txt1
-rw-r--r--CHANGES.txt4
-rw-r--r--coverage/html.py6
-rw-r--r--coverage/htmlfiles/index.html4
-rw-r--r--coverage/htmlfiles/pyfile.html3
-rw-r--r--tests/test_html.py11
6 files changed, 20 insertions, 9 deletions
diff --git a/AUTHORS.txt b/AUTHORS.txt
index 66e27aa..6b38f9c 100644
--- a/AUTHORS.txt
+++ b/AUTHORS.txt
@@ -17,6 +17,7 @@ Chris Adams
Chris Rose
Christian Heimes
Christoph Zwerschke
+Conrad Ho
Danek Duvall
Danny Allen
David Christian
diff --git a/CHANGES.txt b/CHANGES.txt
index edc9af5..1871b3b 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -17,11 +17,15 @@ Latest
(`issue 360`_). It's always fun when the problem is due to a `bug in the
Python standard library <http://bugs.python.org/issue19035>`_.
+- HTML reports now include a timestamp in the footer, closing `issue 299`_.
+ Thanks, Conrad Ho.
+
- HTML reports now begrudgingly use double-quotes rather than single quotes,
because there are "software engineers" out there writing tools that read HTML
and somehow have no idea that single quotes exist. Fixes `issue 361`_.
Thanks, Jon Chappell.
+.. _issue 299: https://bitbucket.org/ned/coveragepy/issue/299/inserted-created-on-yyyy-mm-dd-hh-mm-in
.. _issue 308: https://bitbucket.org/ned/coveragepy/issue/308/yield-lambda-branch-coverage
.. _issue 324: https://bitbucket.org/ned/coveragepy/issue/324/yield-in-loop-confuses-branch-coverage
.. _issue 359: https://bitbucket.org/ned/coveragepy/issue/359/xml-report-chunk-error
diff --git a/coverage/html.py b/coverage/html.py
index 2748d64..0b2cc25 100644
--- a/coverage/html.py
+++ b/coverage/html.py
@@ -93,6 +93,7 @@ class HtmlReporter(Reporter):
self.status = HtmlStatus()
self.extra_css = None
self.totals = Numbers()
+ self.time_stamp = datetime.datetime.now().strftime('%Y-%m-%d %H:%M')
def report(self, morfs):
"""Generate an HTML report for `morfs`.
@@ -238,6 +239,7 @@ class HtmlReporter(Reporter):
'c_exc': c_exc, 'c_mis': c_mis, 'c_par': c_par, 'c_run': c_run,
'arcs': self.arcs, 'extra_css': self.extra_css,
'fr': fr, 'nums': nums, 'lines': lines,
+ 'time_stamp': self.time_stamp,
}
html = spaceless(self.source_tmpl.render(template_values))
@@ -262,14 +264,12 @@ 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,
+ 'time_stamp': self.time_stamp,
})
self.write_html(
diff --git a/coverage/htmlfiles/index.html b/coverage/htmlfiles/index.html
index b872d05..1afc57c 100644
--- a/coverage/htmlfiles/index.html
+++ b/coverage/htmlfiles/index.html
@@ -23,7 +23,6 @@
<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" />
@@ -106,7 +105,8 @@
<div id="footer">
<div class="content">
<p>
- <a class="nav" href="{{__url__}}">coverage.py v{{__version__}}</a>
+ <a class="nav" href="{{__url__}}">coverage.py v{{__version__}}</a>,
+ created at {{ time_stamp }}
</p>
</div>
</div>
diff --git a/coverage/htmlfiles/pyfile.html b/coverage/htmlfiles/pyfile.html
index 72b6928..d78ba53 100644
--- a/coverage/htmlfiles/pyfile.html
+++ b/coverage/htmlfiles/pyfile.html
@@ -84,7 +84,8 @@
<div id="footer">
<div class="content">
<p>
- <a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="{{__url__}}">coverage.py v{{__version__}}</a>
+ <a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="{{__url__}}">coverage.py v{{__version__}}</a>,
+ created at {{ time_stamp }}
</p>
</div>
</div>
diff --git a/tests/test_html.py b/tests/test_html.py
index fd16fdd..75169ba 100644
--- a/tests/test_html.py
+++ b/tests/test_html.py
@@ -367,10 +367,15 @@ class HtmlTest(HtmlTestHelpers, CoverageTest):
def test_has_date_stamp_in_index(self):
self.create_initial_files()
self.run_coverage()
+ # Note: in theory this test could fail if the HTML files are created
+ # at 1:23:59.999 and this timestamp is grabbed at 1:24:00.000.
+ footer = "created at {time_stamp}".format(
+ time_stamp=datetime.datetime.now().strftime('%Y-%m-%d %H:%M')
+ )
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 {time_stamp}</p>".format(time_stamp=time_stamp), index)
+ self.assertIn(footer, f.read())
+ with open("htmlcov/main_file_py.html") as f:
+ self.assertIn(footer, f.read())
class HtmlStaticFileTest(CoverageTest):