[util/format] make temperature metric case insensitive

see #664
This commit is contained in:
tobi-wan-kenobi 2020-06-27 15:02:55 +02:00
parent 1484109fe0
commit 954d7545e3
2 changed files with 4 additions and 1 deletions

View file

@ -68,7 +68,7 @@ def astemperature(val, unit="metric"):
:return: temperature representation of the input value
:rtype: string
"""
return "{}°{}".format(int(val), __UNITS.get(unit, __UNITS["default"]))
return "{}°{}".format(int(val), __UNITS.get(unit.lower(), __UNITS["default"]))
def byte(val, fmt="{:.2f}"):

View file

@ -110,4 +110,7 @@ def test_temperature():
assert astemperature(-100, "kelvin") == "-100°K"
def test_temperature_case():
assert astemperature(100, "ImPeRiAl") == "100°F"
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4