def test_show_zero_when_value_is_none_and_show_zero_is_True(self): amount = format_currency(None) self.assertEqual("$0.00", amount)
def test_add_thousand_separator(self): amount = format_currency(1000) self.assertEqual("$1,000.00", amount)
def test_show_empty_string_when_value_is_none_and_show_zero_is_False(self): amount = format_currency(None, show_zero=False) self.assertEqual("", amount)
def test_allow_decimal_precision_to_be_specified(self): amount = format_currency(123.123456, 4) self.assertEqual("$123.1235", amount)
def test_show_default_formatted_dollar_amount_when_amount_is_not_zero(self): amount = format_currency(123) self.assertEqual("$123.00", amount)
def test_show_formatted_zero_amount(self): amount = format_currency(0) self.assertEqual("$0.00", amount)
def test_show_empty_string_when_amount_is_zero_if_show_zero_is_false(self): amount = format_currency(0, show_zero=False) self.assertEqual("", amount)
def format_currency(value, places=2, show_zero="True"): """ Displays value as US currency: $1,500.00 """ show_zero = True if show_zero == "True" else False return formatting.format_currency(value, places, show_zero)