From efbd66bca1e21e7e96ff42d6d2b22ac59ef66e8b Mon Sep 17 00:00:00 2001 From: Adam Mills Date: Thu, 23 Mar 2017 23:56:39 -0400 Subject: [PATCH] Fix flaky template test (#6768) --- tests/helpers/test_template.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/helpers/test_template.py b/tests/helpers/test_template.py index 18656acac51..b6951172c64 100644 --- a/tests/helpers/test_template.py +++ b/tests/helpers/test_template.py @@ -151,13 +151,14 @@ class TestHelpersTemplate(unittest.TestCase): def test_timestamp_custom(self): """Test the timestamps to custom filter.""" + now = dt_util.utcnow() tests = [ (None, None, None, 'None'), (1469119144, None, True, '2016-07-21 16:39:04'), (1469119144, '%Y', True, '2016'), (1469119144, 'invalid', True, 'invalid'), - (dt_util.as_timestamp(dt_util.utcnow()), None, False, - dt_util.now().strftime('%Y-%m-%d %H:%M:%S')) + (dt_util.as_timestamp(now), None, False, + now.strftime('%Y-%m-%d %H:%M:%S')) ] for inp, fmt, local, out in tests: @@ -202,11 +203,12 @@ class TestHelpersTemplate(unittest.TestCase): def test_timestamp_utc(self): """Test the timestamps to local filter.""" + now = dt_util.utcnow() tests = { None: 'None', 1469119144: '2016-07-21 16:39:04', - dt_util.as_timestamp(dt_util.utcnow()): - dt_util.now().strftime('%Y-%m-%d %H:%M:%S') + dt_util.as_timestamp(now): + now.strftime('%Y-%m-%d %H:%M:%S') } for inp, out in tests.items():