mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 08:47:10 +00:00
Fix flaky template test (#6768)
This commit is contained in:
parent
5dfdb9e481
commit
efbd66bca1
@ -151,13 +151,14 @@ class TestHelpersTemplate(unittest.TestCase):
|
|||||||
|
|
||||||
def test_timestamp_custom(self):
|
def test_timestamp_custom(self):
|
||||||
"""Test the timestamps to custom filter."""
|
"""Test the timestamps to custom filter."""
|
||||||
|
now = dt_util.utcnow()
|
||||||
tests = [
|
tests = [
|
||||||
(None, None, None, 'None'),
|
(None, None, None, 'None'),
|
||||||
(1469119144, None, True, '2016-07-21 16:39:04'),
|
(1469119144, None, True, '2016-07-21 16:39:04'),
|
||||||
(1469119144, '%Y', True, '2016'),
|
(1469119144, '%Y', True, '2016'),
|
||||||
(1469119144, 'invalid', True, 'invalid'),
|
(1469119144, 'invalid', True, 'invalid'),
|
||||||
(dt_util.as_timestamp(dt_util.utcnow()), None, False,
|
(dt_util.as_timestamp(now), None, False,
|
||||||
dt_util.now().strftime('%Y-%m-%d %H:%M:%S'))
|
now.strftime('%Y-%m-%d %H:%M:%S'))
|
||||||
]
|
]
|
||||||
|
|
||||||
for inp, fmt, local, out in tests:
|
for inp, fmt, local, out in tests:
|
||||||
@ -202,11 +203,12 @@ class TestHelpersTemplate(unittest.TestCase):
|
|||||||
|
|
||||||
def test_timestamp_utc(self):
|
def test_timestamp_utc(self):
|
||||||
"""Test the timestamps to local filter."""
|
"""Test the timestamps to local filter."""
|
||||||
|
now = dt_util.utcnow()
|
||||||
tests = {
|
tests = {
|
||||||
None: 'None',
|
None: 'None',
|
||||||
1469119144: '2016-07-21 16:39:04',
|
1469119144: '2016-07-21 16:39:04',
|
||||||
dt_util.as_timestamp(dt_util.utcnow()):
|
dt_util.as_timestamp(now):
|
||||||
dt_util.now().strftime('%Y-%m-%d %H:%M:%S')
|
now.strftime('%Y-%m-%d %H:%M:%S')
|
||||||
}
|
}
|
||||||
|
|
||||||
for inp, out in tests.items():
|
for inp, out in tests.items():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user