Commit 36a44ae7 authored by Carl Meyer's avatar Carl Meyer
Browse files

Mocked datetime in the naturaltime tests to avoid sporadic test failure.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17023 bcc190cf-cafb-0310-a4f2-bffc1f526a37
parent 145a77ed
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -159,4 +159,21 @@ class HumanizeTests(TestCase):
            '1 day from now',
            '1 year, 4 months from now',
        ]

        # 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