Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#26126 closed Cleanup/optimization (fixed)

Transient failure of requests.tests.RequestsTests.test_max_age_expiration

Reported by: Simon Charette Owned by: Berker Peksag
Component: Testing framework Version: dev
Severity: Normal Keywords:
Cc: berker.peksag@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Traceback (most recent call last):
  File "/home/jenkins/workspace/pull-requests-trusty/database/postgis/label/trusty-pr/python/python2.7/tests/requests/tests.py", line 240, in test_max_age_expiration
    self.assertEqual(max_age_cookie['expires'], cookie_date(time.time() + 10))
AssertionError: u'Fri, 22-Jan-2016 19:44:54 GMT' != u'Fri, 22-Jan-2016 19:44:55 GMT'
- Fri, 22-Jan-2016 19:44:54 GMT
?                         ^
+ Fri, 22-Jan-2016 19:44:55 GMT
?                         ^

Change History (7)

comment:1 by Berker Peksag, 9 years ago

Cc: berker.peksag@… added
Has patch: set
Owner: changed from nobody to Berker Peksag
Status: newassigned

Pull request: https://github.com/django/django/pull/6130

Alternative solutions:

  • Make assertEqual check less strict: Don't check for the exact return value of cookie_date().
  • Convert assertEqual to assertIn and check if the return value is time.time() + 10 + 1 or time.time() + 10 - 1. This is simpler than the first solution.
  • Mock cookie_date() in HttpResponseBase.set_cookie().

comment:2 by Tim Graham, 9 years ago

Patch needs improvement: set

As noted on the PR, can django.test.utils.freeze_time() help?

comment:3 by Berker Peksag, 9 years ago

Patch needs improvement: unset

Yes, freeze_time() is a better solution. I've updated the PR to use freeze_time(). Thanks!

comment:4 by Tim Graham, 9 years ago

Triage Stage: AcceptedReady for checkin

comment:5 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In b17a9150:

Fixed #26126 -- Fixed transient failure of test_max_age_expiration

comment:6 by Tim Graham <timograham@…>, 9 years ago

In 33b5bb79:

[1.9.x] Fixed #26126 -- Fixed transient failure of test_max_age_expiration

Backport of b17a9150a0c3a132e82b53755ede62a45f897875 from master

comment:7 by Tim Graham <timograham@…>, 9 years ago

In 927f43ea:

[1.8.x] Fixed #26126 -- Fixed transient failure of test_max_age_expiration

Backport of b17a9150a0c3a132e82b53755ede62a45f897875 from master

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