Fix flaky template test (#6768)

This commit is contained in:
Adam Mills 2017-03-23 23:56:39 -04:00 committed by Paulus Schoutsen
parent 5dfdb9e481
commit efbd66bca1

View file

@ -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():