Fixed the humanize tests to work properly with a pure-python datetime module (platforms such as PyPy)

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17144 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Alex Gaynor 2011-11-22 09:20:58 +00:00
parent 8ddecc39db
commit e71f33625c
1 changed files with 5 additions and 2 deletions

View File

@ -1,5 +1,7 @@
from __future__ import with_statement from __future__ import with_statement
import datetime import datetime
import new
from django.template import Template, Context, defaultfilters from django.template import Template, Context, defaultfilters
from django.test import TestCase from django.test import TestCase
@ -182,12 +184,13 @@ class HumanizeTests(TestCase):
from django.contrib.humanize.templatetags import humanize from django.contrib.humanize.templatetags import humanize
from django.utils import timesince from django.utils import timesince
orig_humanize_datetime = humanize.datetime orig_humanize_datetime = humanize.datetime
orig_timesince_datetime = timesince.datetime.datetime orig_timesince_datetime = timesince.datetime
humanize.datetime = MockDateTime humanize.datetime = MockDateTime
timesince.datetime = new.module("mock_datetime")
timesince.datetime.datetime = MockDateTime timesince.datetime.datetime = MockDateTime
try: try:
self.humanize_tester(test_list, result_list, 'naturaltime') self.humanize_tester(test_list, result_list, 'naturaltime')
finally: finally:
humanize.datetime = orig_humanize_datetime humanize.datetime = orig_humanize_datetime
timesince.datetime.datetime = orig_timesince_datetime timesince.datetime = orig_timesince_datetime