Code

Opened 3 years ago

Closed 2 years ago

#16991 closed Bug (fixed)

Humanize tests fail randomly

Reported by: akaariai 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?

Attachments (0)

Change History (2)

comment:1 Changed 3 years ago by julien

  • Component changed from Testing framework to contrib.humanize
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

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 Changed 2 years ago by claudep

  • Resolution set to fixed
  • Status changed from new to closed

Probably fixed by changeset:17023

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.