From e6a4ab30db81bc088892c060d63f9b87d3e9d78b Mon Sep 17 00:00:00 2001 From: "dpranke@chromium.org" Date: Thu, 31 Mar 2011 01:23:08 +0000 Subject: [PATCH] merge in fixes for python 2.5 R=maruel@chromium.org Review URL: http://codereview.chromium.org/6740012 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@79942 0039d316-1c4b-4281-b951-d872f2087c98 --- owners.py | 7 ++++--- tests/owners_unittest.py | 9 ++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/owners.py b/owners.py index 18dd31153..5aabb6007 100644 --- a/owners.py +++ b/owners.py @@ -17,9 +17,10 @@ BASIC_EMAIL_REGEXP = r'^[\w\-\+\%\.]+\@[\w\-\+\%\.]+$' def _assert_is_collection(obj): - assert (isinstance(obj, collections.Iterable) and - isinstance(obj, collections.Sized) and - not isinstance(obj, basestring)) + assert not isinstance(obj, basestring) + if hasattr(collections, 'Iterable') and hasattr(collections, 'Sized'): + assert (isinstance(obj, collections.Iterable) and + isinstance(obj, collections.Sized)) class SyntaxErrorInOwnersFile(Exception): diff --git a/tests/owners_unittest.py b/tests/owners_unittest.py index 1ac7a5e20..92029bc60 100755 --- a/tests/owners_unittest.py +++ b/tests/owners_unittest.py @@ -109,8 +109,9 @@ class OwnersDatabaseTest(unittest.TestCase): # Check that we're passed in a sequence that isn't a string. self.assertRaises(AssertionError, db.files_not_covered_by, 'foo', []) - self.assertRaises(AssertionError, db.files_not_covered_by, - (f for f in ['x', 'y']), []) + if hasattr(owners.collections, 'Iterable'): + self.assertRaises(AssertionError, db.files_not_covered_by, + (f for f in ['x', 'y']), []) # Check that the files are under the root. db.root = '/checkout' @@ -139,7 +140,9 @@ class OwnersDatabaseTest(unittest.TestCase): # Check that we're passed in a sequence that isn't a string. self.assertRaises(AssertionError, db.reviewers_for, 'foo') - self.assertRaises(AssertionError, db.reviewers_for, (f for f in ['x', 'y'])) + if hasattr(owners.collections, 'Iterable'): + self.assertRaises(AssertionError, db.reviewers_for, + (f for f in ['x', 'y'])) # Check that the files are under the root. db.root = '/checkout'