Additional edits for refs #23340; thanks Loic.
This commit is contained in:
parent
7353e26d5d
commit
0a2bc6e6bd
|
@ -270,7 +270,6 @@ class HumanizeTests(TestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
class DocumentedMockDateTime(datetime.datetime):
|
class DocumentedMockDateTime(datetime.datetime):
|
||||||
"""Override Class for humanize.datetime """
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def now(cls, tz=None):
|
def now(cls, tz=None):
|
||||||
if tz is None or tz.utcoffset(documented_now) is None:
|
if tz is None or tz.utcoffset(documented_now) is None:
|
||||||
|
@ -278,8 +277,12 @@ class HumanizeTests(TestCase):
|
||||||
else:
|
else:
|
||||||
return documented_now.replace(tzinfo=tz) + tz.utcoffset(now)
|
return documented_now.replace(tzinfo=tz) + tz.utcoffset(now)
|
||||||
|
|
||||||
|
orig_humanize_datetime = humanize.datetime
|
||||||
humanize.datetime = DocumentedMockDateTime
|
humanize.datetime = DocumentedMockDateTime
|
||||||
for test_time_string, expected_natural_time in test_data:
|
try:
|
||||||
test_time = datetime.datetime.strptime(test_time_string, time_format)
|
for test_time_string, expected_natural_time in test_data:
|
||||||
natural_time = humanize.naturaltime(test_time).replace('\xa0', ' ')
|
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)
|
self.assertEqual(expected_natural_time, natural_time)
|
||||||
|
finally:
|
||||||
|
humanize.datetime = orig_humanize_datetime
|
||||||
|
|
Loading…
Reference in New Issue