<commit_before><commit_msg>Add unittests for *utility/test_numify*<commit_after>import unittest
from utility.formatting import numify, commify


class TestFormatting(unittest.TestCase):
    """Test formatting numbers by numifying or commifying"""

    def test_numify(self):
        "Test that a number is correctly converted to a English readable string"
        self.assertEqual(numify(1, 'item', 'items'),
                         'one item')
        self.assertEqual(numify(2, 'book'), 'two')
        self.assertEqual(numify(2, 'book', 'books'), 'two books')
        self.assertEqual(numify(0, 'book', 'books'), 'zero books')
        self.assertEqual(numify(0), 'zero')
        self.assertEqual(numify(5), 'five')
        self.assertEqual(numify(14, 'book', 'books'), '14 books')
        self.assertEqual(numify(999, 'book', 'books'), '999 books')
        self.assertEqual(numify(1000000, 'book', 'books'), '1,000,000 books')
        self.assertEqual(numify(1956), '1956')

    def test_commify(self):
        "Test that commas are added correctly"
        self.assertEqual(commify(1), '1')
        self.assertEqual(commify(123), '123')
        self.assertEqual(commify(1234), '1234')
        self.assertEqual(commify(12345), '12,345')
        self.assertEqual(commify(1234567890), '1,234,567,890')
        self.assertEqual(commify(123.0), '123.0')
        self.assertEqual(commify(1234.5), '1234.5')
        self.assertEqual(commify(1234.56789), '1234.56789')
        self.assertEqual(commify(123456.789), '123,456.789')
        self.assertEqual(commify(None), None)

{'fraction_non_alphanumeric': 0.15458015267175573, 'fraction_numerical': 0.08778625954198473, 'mean_word_length': 3.507163323782235, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3815061', 'n_tokens_mistral': 570, 'n_tokens_neox': 481, 'n_words': 100}