mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Add 'method' parameter to forgiving_round method (#21708)
* Add 'method' parameter to forgiving_round method Fixes #21707 * fix rounding behavior in round() filter * add test cases for new rounding behaviour
This commit is contained in:
committed by
Robbie Trencheny
parent
548371e94c
commit
f272ed3b91
@@ -97,6 +97,16 @@ class TestHelpersTemplate(unittest.TestCase):
|
||||
'{{ states.sensor.temperature.state | multiply(10) | round }}',
|
||||
self.hass).render()
|
||||
|
||||
assert '12.7' == \
|
||||
template.Template(
|
||||
'{{ states.sensor.temperature.state | round(1, "floor") }}',
|
||||
self.hass).render()
|
||||
|
||||
assert '12.8' == \
|
||||
template.Template(
|
||||
'{{ states.sensor.temperature.state | round(1, "ceil") }}',
|
||||
self.hass).render()
|
||||
|
||||
def test_rounding_value_get_original_value_on_error(self):
|
||||
"""Test rounding value get original value on error."""
|
||||
assert 'None' == \
|
||||
|
||||
Reference in New Issue
Block a user