コード例 #1
0
    def test_ten_gets_no_comma(self):
        number = 20

        result = human_readable_numbers.humanise_number(number)

        self.assertEqual(result.locale_string.count(','), 0)
        self.assertEqual(int(result.locale_string.replace(',', '')), number)
コード例 #2
0
    def test_next_over_trillion_gets_five_comma(self):
        number = 2 * (10**15)

        result = human_readable_numbers.humanise_number(number)

        self.assertEqual(result.locale_string.count(','), 5)
        self.assertEqual(int(result.locale_string.replace(',', '')), number)
コード例 #3
0
    def test_ten_thousand_gets_one_comma(self):
        number = 12345

        result = human_readable_numbers.humanise_number(number)

        self.assertEqual(result.locale_string.count(','), 1)
        self.assertEqual(int(result.locale_string.replace(',', '')), number)
コード例 #4
0
    def test_next_over_trillion_gets_unformatted_magnitude(self):
        number = 2 * (10**15)

        result = human_readable_numbers.humanise_number(number)

        self.assertEqual(result.magnitude_string, '2,000 trillion')
コード例 #5
0
    def test_million_gets_one_million_magnitude(self):
        number = 2000000

        result = human_readable_numbers.humanise_number(number)

        self.assertEqual(result.magnitude_string, '2 million')
コード例 #6
0
    def test_thousand_gets_thousand_magnitude(self):
        number = 2000

        result = human_readable_numbers.humanise_number(number)

        self.assertEqual(result.magnitude_string, '2 thousand')
コード例 #7
0
    def test_ten_thousand_gets_thousand_magnitude(self):
        number = 12345

        result = human_readable_numbers.humanise_number(number)

        self.assertEqual(result.magnitude_string, '12 thousand 3 hundred 45')
コード例 #8
0
    def test_hundred_gets_one_hundred_magnitude(self):
        number = 200

        result = human_readable_numbers.humanise_number(number)

        self.assertEqual(result.magnitude_string, '2 hundred')