fix: include thousands separator for app.render_quantity()
This commit is contained in:
parent
37cf3c4400
commit
78600c8cc2
2 changed files with 10 additions and 2 deletions
|
|
@ -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):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue