Author: carljm Date: 2011-10-21 23:06:44 -0700 (Fri, 21 Oct 2011) New Revision: 17023
Modified: django/trunk/django/contrib/humanize/tests.py Log: Mocked datetime in the naturaltime tests to avoid sporadic test failure. Modified: django/trunk/django/contrib/humanize/tests.py =================================================================== --- django/trunk/django/contrib/humanize/tests.py 2011-10-22 04:30:10 UTC (rev 17022) +++ django/trunk/django/contrib/humanize/tests.py 2011-10-22 06:06:44 UTC (rev 17023) @@ -159,4 +159,21 @@ '1 day from now', '1 year, 4 months from now', ] - self.humanize_tester(test_list, result_list, 'naturaltime') + + # mock out datetime so these tests don't fail occasionally when the + # test runs too slow + class MockDateTime(object): + def now(self): + return now + + def __call__(self, *args, **kwargs): + return datetime(*args, **kwargs) + + from django.contrib.humanize.templatetags import humanize + orig_datetime = humanize.datetime + humanize.datetime = MockDateTime() + + try: + self.humanize_tester(test_list, result_list, 'naturaltime') + finally: + humanize.datetime = orig_datetime -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.