Opened 13 years ago

Closed 13 years ago

#16991 closed Bug (fixed)

Humanize tests fail randomly

Reported by: Anssi Kääriäinen Owned by: nobody
Component: contrib.humanize Version: 1.3
Severity: Normal Keywords: humanize test
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I have now gotten two times this error:

======================================================================
FAIL: test_naturaltime (django.contrib.humanize.tests.HumanizeTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/akaj/Django/tests/django/contrib/humanize/tests.py", line 162, in test_naturaltime
    self.humanize_tester(test_list, result_list, 'naturaltime')
  File "/home/akaj/Django/tests/django/contrib/humanize/tests.py", line 22, in humanize_tester
    msg="%s test failed, produced '%s', should've produced '%s'" % (method, rendered, result))
AssertionError: u'31 seconds ago' != u'30 seconds ago' : naturaltime test failed, produced '31 seconds ago', should've produced '30 seconds ago'

(The another time was 2 minutes ago <> 1 minute ago).

I am using an old laptop, so timing issues are more likely to pop out on my setup. And this is almost certainly because of timing issues.

BTW is it correct to mark the component as testing framework?

Change History (2)

comment:1 by Julien Phalip, 13 years ago

Component: Testing frameworkcontrib.humanize
Triage Stage: UnreviewedAccepted

I can imagine this problem happen on slow machines since the datetime.now() function is effectively called twice: first in the test and then again in the naturaltime filter.

Maybe a more robust way of testing would be to temporarily monkey-patch the datetime.now() function in the humanize tests.

comment:2 by Claude Paroz, 13 years ago

Resolution: fixed
Status: newclosed

Probably fixed by changeset:17023

Note: See TracTickets for help on using tickets.
Back to Top