summaryrefslogtreecommitdiff
path: root/tests/test_html.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2015-04-25 09:31:06 -0400
committerNed Batchelder <ned@nedbatchelder.com>2015-04-25 09:31:06 -0400
commit9cb10daca96cd61bb4c7afdd4affb6c878e22245 (patch)
tree51f1bbc65c91c961763b4d2fc88480003bcb5b9b /tests/test_html.py
parent087da3175829f5fdb0db0c372872b905304cda55 (diff)
downloadpython-coveragepy-git-9cb10daca96cd61bb4c7afdd4affb6c878e22245.tar.gz
Refactor datetime recency testing into a tested test helper
Diffstat (limited to 'tests/test_html.py')
-rw-r--r--tests/test_html.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/tests/test_html.py b/tests/test_html.py
index 6f0b294a..6f6f42e4 100644
--- a/tests/test_html.py
+++ b/tests/test_html.py
@@ -386,16 +386,13 @@ class HtmlTest(HtmlTestHelpers, CoverageTest):
m = re.search(timestamp_pat, html)
self.assertTrue(m, "Didn't find a timestamp!")
timestamp = datetime.datetime(*map(int, m.groups()))
- age = datetime.datetime.now() - timestamp
- # Python2.6 doesn't have total_seconds :(
- self.assertEqual(age.days, 0)
# The timestamp only records the minute, so the delta could be from
# 12:00 to 12:01:59, or two minutes.
- self.assertLessEqual(
- abs(age.seconds),
- 120,
- "Timestamp is wrong: {0}".format(timestamp)
- )
+ self.assert_recent_datetime(
+ timestamp,
+ seconds=120,
+ msg="Timestamp is wrong: {0}".format(timestamp),
+ )
class HtmlStaticFileTest(CoverageTest):