0
0
mirror of https://github.com/django/django.git synced 2024-12-01 15:42:04 +01:00

Additional edits for refs #23340; thanks Loic.

This commit is contained in:
Tim Graham 2014-09-06 07:59:27 -04:00
parent 7353e26d5d
commit 0a2bc6e6bd

View File

@ -270,7 +270,6 @@ class HumanizeTests(TestCase):
)
class DocumentedMockDateTime(datetime.datetime):
"""Override Class for humanize.datetime """
@classmethod
def now(cls, tz=None):
if tz is None or tz.utcoffset(documented_now) is None:
@ -278,8 +277,12 @@ class HumanizeTests(TestCase):
else:
return documented_now.replace(tzinfo=tz) + tz.utcoffset(now)
orig_humanize_datetime = humanize.datetime
humanize.datetime = DocumentedMockDateTime
for test_time_string, expected_natural_time in test_data:
test_time = datetime.datetime.strptime(test_time_string, time_format)
natural_time = humanize.naturaltime(test_time).replace('\xa0', ' ')
try:
for test_time_string, expected_natural_time in test_data:
test_time = datetime.datetime.strptime(test_time_string, time_format)
natural_time = humanize.naturaltime(test_time).replace('\xa0', ' ')
self.assertEqual(expected_natural_time, natural_time)
finally:
humanize.datetime = orig_humanize_datetime