diff --git a/src/wuttjamaican/app.py b/src/wuttjamaican/app.py index 044331f..3b7ef86 100644 --- a/src/wuttjamaican/app.py +++ b/src/wuttjamaican/app.py @@ -962,8 +962,8 @@ class AppHandler: # pylint: disable=too-many-public-methods value = int(value) if empty_zero and value == 0: return "" - return str(value) - return str(value).rstrip("0") + return f"{value:,}" + return f"{value:,}".rstrip("0") def render_time_ago(self, value): """ diff --git a/tests/test_app.py b/tests/test_app.py index cd2236b..7bdebf9 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -672,6 +672,14 @@ app_title = WuttaTest self.assertEqual(self.app.render_quantity(0), "0") self.assertEqual(self.app.render_quantity(0, empty_zero=True), "") + # has thousands separator + value = 1234 + self.assertEqual(self.app.render_quantity(value), "1,234") + value = decimal.Decimal("1234.567") + self.assertEqual(self.app.render_quantity(value), "1,234.567") + value = decimal.Decimal("1234.567000") + self.assertEqual(self.app.render_quantity(value), "1,234.567") + def test_render_time_ago(self): with patch.object(mod, "humanize") as humanize: humanize.naturaltime.return_value = "now"