From 954d7545e38394088a363d04cc98f234c0610087 Mon Sep 17 00:00:00 2001 From: tobi-wan-kenobi Date: Sat, 27 Jun 2020 15:02:55 +0200 Subject: [PATCH] [util/format] make temperature metric case insensitive see #664 --- bumblebee_status/util/format.py | 2 +- tests/util/test_format.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/bumblebee_status/util/format.py b/bumblebee_status/util/format.py index 198e995..65242a3 100644 --- a/bumblebee_status/util/format.py +++ b/bumblebee_status/util/format.py @@ -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}"): diff --git a/tests/util/test_format.py b/tests/util/test_format.py index 4dda6e9..1e34dec 100644 --- a/tests/util/test_format.py +++ b/tests/util/test_format.py @@ -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