From 786886257e72162460594f411dee48250967f753 Mon Sep 17 00:00:00 2001 From: "maruel@chromium.org" Date: Thu, 28 May 2009 21:20:58 +0000 Subject: [PATCH] warnings.catch_warnings() is only available on python 2.5 Review URL: http://codereview.chromium.org/115881 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@17114 0039d316-1c4b-4281-b951-d872f2087c98 --- tests/presubmit_unittest.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/presubmit_unittest.py b/tests/presubmit_unittest.py index 7f5d57191c..32a3829ed0 100755 --- a/tests/presubmit_unittest.py +++ b/tests/presubmit_unittest.py @@ -21,7 +21,11 @@ import presubmit_canned_checks class PresubmitTestsBase(unittest.TestCase): """Setups and tear downs the mocks but doesn't test anything as-is.""" def setUp(self): - self._warnings_stack = warnings.catch_warnings() + if hasattr(warnings, 'catch_warnings'): + self._warnings_stack = warnings.catch_warnings() + else: + self._warnings_stack = None + warnings.simplefilter("ignore", DeprecationWarning) self.original_IsFile = os.path.isfile def MockIsFile(f):