Ticket #24181: patch_24181.diff

File patch_24181.diff, 1.3 KB (added by Varun Sharma, 10 years ago)

Added unit test to the patch

  • django/utils/numberformat.py

    diff --git a/django/utils/numberformat.py b/django/utils/numberformat.py
    index dcccc99..3f61a66 100644
    a b def format(number, decimal_sep, decimal_pos=None, grouping=0, thousand_sep='',  
    4747        int_part_gd = ''
    4848        for cnt, digit in enumerate(int_part[::-1]):
    4949            if cnt and not cnt % grouping:
    50                 int_part_gd += thousand_sep
     50                int_part_gd += thousand_sep[::-1]
    5151            int_part_gd += digit
    5252        int_part = int_part_gd[::-1]
    5353    return sign + int_part + dec_part
  • tests/utils_tests/test_numberformat.py

    diff --git a/tests/utils_tests/test_numberformat.py b/tests/utils_tests/test_numberformat.py
    index 84ba378..4357906 100644
    a b class TestNumberFormat(TestCase):  
    2626        self.assertEqual(nformat('1234', '.', grouping=2, thousand_sep=',',
    2727                                 force_grouping=True), '12,34')
    2828        self.assertEqual(nformat('-1234.33', '.', decimal_pos=1), '-1234.3')
     29        self.assertEqual(nformat('10000', '.', grouping=3,
     30                                 thousand_sep='comma', force_grouping=True),
     31                         '10comma000')
    2932
    3033    def test_large_number(self):
    3134        most_max = ('{}179769313486231570814527423731704356798070567525844996'
Back to Top