Completed test coverage of contrib.humanize.templatetags.humanize.

This commit is contained in:
Hasan Ramezani 2018-11-11 01:09:37 +01:00 committed by Tim Graham
parent 961f8e9985
commit c7cc7526d5
1 changed files with 7 additions and 2 deletions

View File

@ -98,12 +98,13 @@ class HumanizeTests(SimpleTestCase):
test_list = ( test_list = (
'100', '1000000', '1200000', '1290000', '1000000000', '2000000000', '100', '1000000', '1200000', '1290000', '1000000000', '2000000000',
'6000000000000', '1300000000000000', '3500000000000000000000', '6000000000000', '1300000000000000', '3500000000000000000000',
'8100000000000000000000000000000000', None, '8100000000000000000000000000000000', None, ('1' + '0' * 100),
('1' + '0' * 104),
) )
result_list = ( result_list = (
'100', '1.0 million', '1.2 million', '1.3 million', '1.0 billion', '100', '1.0 million', '1.2 million', '1.3 million', '1.0 billion',
'2.0 billion', '6.0 trillion', '1.3 quadrillion', '3.5 sextillion', '2.0 billion', '6.0 trillion', '1.3 quadrillion', '3.5 sextillion',
'8.1 decillion', None, '8.1 decillion', None, '1.0 googol', ('1' + '0' * 104),
) )
with translation.override('en'): with translation.override('en'):
self.humanize_tester(test_list, result_list, 'intword') self.humanize_tester(test_list, result_list, 'intword')
@ -183,7 +184,9 @@ class HumanizeTests(SimpleTestCase):
def utcoffset(self, dt): def utcoffset(self, dt):
return None return None
test_list = [ test_list = [
'test',
now, now,
now - datetime.timedelta(microseconds=1),
now - datetime.timedelta(seconds=1), now - datetime.timedelta(seconds=1),
now - datetime.timedelta(seconds=30), now - datetime.timedelta(seconds=30),
now - datetime.timedelta(minutes=1, seconds=30), now - datetime.timedelta(minutes=1, seconds=30),
@ -205,6 +208,8 @@ class HumanizeTests(SimpleTestCase):
now.replace(tzinfo=utc), now.replace(tzinfo=utc),
] ]
result_list = [ result_list = [
'test',
'now',
'now', 'now',
'a second ago', 'a second ago',
'30\xa0seconds ago', '30\xa0seconds ago',