Merge lp:~mwhudson/launchpad/fix-test_min_time_to_next_builder-non-utc-bug-525329 into lp:launchpad

Proposed by Michael Hudson-Doyle
Status: Merged
Approved by: Michael Hudson-Doyle
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~mwhudson/launchpad/fix-test_min_time_to_next_builder-non-utc-bug-525329
Merge into: lp:launchpad
Diff against target: 30 lines (+3/-4)
1 file modified
lib/lp/buildmaster/tests/test_buildqueue.py (+3/-4)
To merge this branch: bzr merge lp:~mwhudson/launchpad/fix-test_min_time_to_next_builder-non-utc-bug-525329
Reviewer Review Type Date Requested Status
Māris Fogels (community) Approve
Paul Hummer (community) code Approve
Tim Penhey (community) Approve
Aaron Bentley (community) Approve
Review via email: mp+21082@code.launchpad.net

Commit message

test_min_time_to_next_builder fails in timezones ahead of UTC

Description of the change

As discussed in our standup.

To post a comment you must log in.
Revision history for this message
Aaron Bentley (abentley) :
review: Approve
Revision history for this message
Tim Penhey (thumper) :
review: Approve
Revision history for this message
Paul Hummer (rockstar) :
review: Approve (code)
Revision history for this message
Māris Fogels (mars) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/buildmaster/tests/test_buildqueue.py'
2--- lib/lp/buildmaster/tests/test_buildqueue.py 2010-03-08 12:53:59 +0000
3+++ lib/lp/buildmaster/tests/test_buildqueue.py 2010-03-10 21:05:38 +0000
4@@ -96,8 +96,7 @@
5 queue_entry.lastscore)
6
7
8-def check_mintime_to_builder(
9- test, bq, min_time, time_stamp=datetime.utcnow()):
10+def check_mintime_to_builder(test, bq, min_time):
11 """Test the estimated time until a builder becomes available."""
12 # Monkey-patch BuildQueueSet._now() so it returns a constant time stamp
13 # that's not too far in the future. This avoids spurious test failures.
14@@ -113,7 +112,7 @@
15 """Set remaining running time for job."""
16 offset = bq.estimated_duration.seconds - remainder
17 bq.setDateStarted(
18- datetime.utcnow().replace(tzinfo=utc) - timedelta(seconds=offset))
19+ datetime.now(utc) - timedelta(seconds=offset))
20
21
22 def check_delay_for_job(test, the_job, delay):
23@@ -143,7 +142,7 @@
24 # Use the date/time the job started if available.
25 time_stamp = buildqueue.job.date_started
26 if not time_stamp:
27- time_stamp = datetime.utcnow()
28+ time_stamp = datetime.now(utc)
29 buildqueue._now = lambda: time_stamp
30 return time_stamp
31