Skip to content

Commit

Permalink
fix py25 compat: strptime doesn't support %f
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Apr 7, 2014
1 parent af58804 commit c1652f9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
4 changes: 3 additions & 1 deletion master/buildbot/changes/bitbucket.py
Expand Up @@ -112,7 +112,9 @@ def _processChanges(self, page):
prlink = pr['links']['html']['href']
# Get time updated time. Note that the timezone offset is ignored.
if self.useTimestamps:
updated = datetime.strptime(pr['updated_on'][:-6], '%Y-%m-%dT%H:%M:%S.%f')
updated = datetime.strptime(
pr['updated_on'].split('.')[0],
'%Y-%m-%dT%H:%M:%S')
else:
updated = datetime.now()
title = pr['title']
Expand Down
14 changes: 8 additions & 6 deletions master/buildbot/test/unit/test_changes_bitbucket.py
Expand Up @@ -255,6 +255,8 @@ class TestBitbucketPullrequestPoller(changesource.ChangeSourceMixin, unittest.Te
def setUp(self):
# create pull requests
self.date = "2013-10-15T20:38:20.001797+00:00"
self.date_epoch = datetime.strptime(self.date.split('.')[0],
'%Y-%m-%dT%H:%M:%S')
src = SourceRest(
owner="contributor",
slug="slug",
Expand Down Expand Up @@ -368,7 +370,7 @@ def check(_):
self.assertEqual(self.changes_added[0]['author'], "contributor")
self.assertEqual(int(self.changes_added[0]['revision']), 1)
self.assertEqual(self.changes_added[0]['when_timestamp'],
datetime.strptime(self.date[:-6], '%Y-%m-%dT%H:%M:%S.%f'))
self.date_epoch)

d.addCallback(check)
return d
Expand All @@ -385,7 +387,7 @@ def check(_):
self.assertEqual(self.changes_added[0]['author'], "contributor")
self.assertEqual(int(self.changes_added[0]['revision']), 1)
self.assertEqual(self.changes_added[0]['when_timestamp'],
datetime.strptime(self.date[:-6], '%Y-%m-%dT%H:%M:%S.%f'))
self.date_epoch)

# repoll
d = self.changesource.poll()
Expand All @@ -410,7 +412,7 @@ def check(_):
self.assertEqual(self.changes_added[0]['author'], "contributor")
self.assertEqual(int(self.changes_added[0]['revision']), 1)
self.assertEqual(self.changes_added[0]['when_timestamp'],
datetime.strptime(self.date[:-6], '%Y-%m-%dT%H:%M:%S.%f'))
self.date_epoch)

self.patch(client, "getPage", self.pr_list2.getPage)
d = self.changesource.poll()
Expand All @@ -420,7 +422,7 @@ def check2(_):
self.assertEqual(self.changes_added[1]['author'], "contributor")
self.assertEqual(int(self.changes_added[1]['revision']), 2)
self.assertEqual(self.changes_added[1]['when_timestamp'],
datetime.strptime(self.date[:-6], '%Y-%m-%dT%H:%M:%S.%f'))
self.date_epoch)

d.addCallback(check2)
return d
Expand Down Expand Up @@ -463,7 +465,7 @@ def check(_):
self.assertEqual(self.changes_added[0]['author'], "contributor")
self.assertEqual(int(self.changes_added[0]['revision']), 1)
self.assertEqual(self.changes_added[0]['when_timestamp'],
datetime.strptime(self.date[:-6], '%Y-%m-%dT%H:%M:%S.%f'))
self.date_epoch)

d.addCallback(check)
return d
Expand All @@ -485,7 +487,7 @@ def check(_):
self.assertEqual(self.changes_added[0]['author'], "contributor")
self.assertEqual(int(self.changes_added[0]['revision']), 1)
self.assertNotEqual(self.changes_added[0]['when_timestamp'],
datetime.strptime(self.date[:-6], '%Y-%m-%dT%H:%M:%S.%f'))
self.date_epoch)

d.addCallback(check)
return d

0 comments on commit c1652f9

Please sign in to comment.