mirror of
https://github.com/django/django.git
synced 2025-03-31 19:46:42 +00:00
[1.6.x] Additional edits for refs #23340; thanks Loic.
Backport of 0a2bc6e6bd from master
This commit is contained in:
parent
c9e0afe2d3
commit
8635fa0b11
@ -261,7 +261,6 @@ class HumanizeTests(TransRealMixin, 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:
|
||||||
@ -269,8 +268,12 @@ class HumanizeTests(TransRealMixin, 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…
x
Reference in New Issue
Block a user