Title: [97171] trunk/Tools
Revision
97171
Author
[email protected]
Date
2011-10-11 13:21:23 -0700 (Tue, 11 Oct 2011)

Log Message

watchlist: assertRaisesRegexp implementation should be compatible with python 2.7.
https://bugs.webkit.org/show_bug.cgi?id=69789

Reviewed by Eric Seidel.

Made the signature of _assertRaisesRegexp match that of Python 2.7.

* Scripts/webkitpy/common/watchlist/watchlistloader_unittest.py: Adjusted to be compatible with Python 2.7.
* Scripts/webkitpy/common/watchlist/watchlistparser_unittest.py: Ditto.
* Scripts/webkitpy/common/webkitunittest.py: Ditto.
* Scripts/webkitpy/tool/commands/applywatchlistlocal_unittest.py: Ditto.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (97170 => 97171)


--- trunk/Tools/ChangeLog	2011-10-11 19:56:28 UTC (rev 97170)
+++ trunk/Tools/ChangeLog	2011-10-11 20:21:23 UTC (rev 97171)
@@ -1,3 +1,17 @@
+2011-10-11  David Levin  <[email protected]>
+
+        watchlist: assertRaisesRegexp implementation should be compatible with python 2.7.
+        https://bugs.webkit.org/show_bug.cgi?id=69789
+
+        Reviewed by Eric Seidel.
+
+        Made the signature of _assertRaisesRegexp match that of Python 2.7.
+
+        * Scripts/webkitpy/common/watchlist/watchlistloader_unittest.py: Adjusted to be compatible with Python 2.7.
+        * Scripts/webkitpy/common/watchlist/watchlistparser_unittest.py: Ditto.
+        * Scripts/webkitpy/common/webkitunittest.py: Ditto.
+        * Scripts/webkitpy/tool/commands/applywatchlistlocal_unittest.py: Ditto.
+
 2011-10-11  Raphael Kubo da Costa  <[email protected]>
 
         [EFL] DRT: Do not abort() when an unknown key is pressed.

Modified: trunk/Tools/Scripts/webkitpy/common/watchlist/watchlistloader_unittest.py (97170 => 97171)


--- trunk/Tools/Scripts/webkitpy/common/watchlist/watchlistloader_unittest.py	2011-10-11 19:56:28 UTC (rev 97170)
+++ trunk/Tools/Scripts/webkitpy/common/watchlist/watchlistloader_unittest.py	2011-10-11 20:21:23 UTC (rev 97171)
@@ -37,7 +37,7 @@
 class WatchListLoaderTest(webkitunittest.TestCase):
     def test_watch_list_not_found(self):
         loader = WatchListLoader(filesystem_mock.MockFileSystem())
-        self.assertRaisesRegexp(r'Watch list file \(.*/watchlist\) not found\.', loader.load)
+        self.assertRaisesRegexp(Exception, r'Watch list file \(.*/watchlist\) not found\.', loader.load)
 
     def test_watch_list_load(self):
         # Test parsing of the checked-in watch list.

Modified: trunk/Tools/Scripts/webkitpy/common/watchlist/watchlistparser_unittest.py (97170 => 97171)


--- trunk/Tools/Scripts/webkitpy/common/watchlist/watchlistparser_unittest.py	2011-10-11 19:56:28 UTC (rev 97170)
+++ trunk/Tools/Scripts/webkitpy/common/watchlist/watchlistparser_unittest.py	2011-10-11 20:21:23 UTC (rev 97171)
@@ -39,13 +39,14 @@
 
     def test_bad_section(self):
         watch_list_with_bad_section = ('{"FOO": {}}')
-        self.assertRaisesRegexp('Unknown section "FOO" in watch list.',
+        self.assertRaisesRegexp(Exception, 'Unknown section "FOO" in watch list.',
                                 self._watch_list_parser.parse, watch_list_with_bad_section)
 
     def test_section_typo(self):
         watch_list_with_bad_section = ('{"DEFINTIONS": {}}')
-        self.assertRaisesRegexp(r'Unknown section "DEFINTIONS" in watch list\.\s*'
-                              + r'Perhaps it should be DEFINITIONS\.',
+        self.assertRaisesRegexp(Exception,
+                                r'Unknown section "DEFINTIONS" in watch list\.\s*'
+                                + r'Perhaps it should be DEFINITIONS\.',
                                 self._watch_list_parser.parse, watch_list_with_bad_section)
 
     def test_bad_definition(self):
@@ -58,7 +59,7 @@
             '     },'
             '}')
 
-        self.assertRaisesRegexp(r'Invalid character "\|" in definition "WatchList1\|A"\.',
+        self.assertRaisesRegexp(Exception, r'Invalid character "\|" in definition "WatchList1\|A"\.',
                                 self._watch_list_parser.parse, watch_list_with_bad_definition)
 
     def test_bad_match_type(self):
@@ -71,7 +72,7 @@
             '     },'
             '}')
 
-        self.assertRaisesRegexp('Unknown pattern type "nothing_matches_this" in definition "WatchList1".',
+        self.assertRaisesRegexp(Exception, 'Unknown pattern type "nothing_matches_this" in definition "WatchList1".',
                                 self._watch_list_parser.parse, watch_list_with_bad_match_type)
 
     def test_match_type_typo(self):
@@ -84,7 +85,7 @@
             '     },'
             '}')
 
-        self.assertRaisesRegexp(r'Unknown pattern type "iflename" in definition "WatchList1"\.\s*'
+        self.assertRaisesRegexp(Exception, r'Unknown pattern type "iflename" in definition "WatchList1"\.\s*'
                                 + r'Perhaps it should be filename\.',
                                 self._watch_list_parser.parse, watch_list_with_bad_match_type)
 
@@ -97,7 +98,7 @@
             '     },'
             '}')
 
-        self.assertRaisesRegexp(r'The definition "WatchList1" has no patterns, so it should be deleted.',
+        self.assertRaisesRegexp(Exception, r'The definition "WatchList1" has no patterns, so it should be deleted.',
                                 self._watch_list_parser.parse, watch_list)
 
     def test_empty_cc_rule(self):
@@ -113,7 +114,7 @@
             '     },'
             '}')
 
-        self.assertRaisesRegexp(r'A rule for definition "WatchList1" is empty, so it should be deleted.',
+        self.assertRaisesRegexp(Exception, r'A rule for definition "WatchList1" is empty, so it should be deleted.',
                                 self._watch_list_parser.parse, watch_list)
 
     def test_empty_message_rule(self):
@@ -130,7 +131,7 @@
             '     },'
             '}')
 
-        self.assertRaisesRegexp(r'A rule for definition "WatchList1" is empty, so it should be deleted.',
+        self.assertRaisesRegexp(Exception, r'A rule for definition "WatchList1" is empty, so it should be deleted.',
                                 self._watch_list_parser.parse, watch_list)
 
     def test_unused_defintion(self):
@@ -143,7 +144,7 @@
             '     },'
             '}')
 
-        self.assertRaisesRegexp(r'The following definitions are not used and should be removed: WatchList1',
+        self.assertRaisesRegexp(Exception, r'The following definitions are not used and should be removed: WatchList1',
                                 self._watch_list_parser.parse, watch_list)
 
     def test_cc_rule_with_undefined_defintion(self):
@@ -154,7 +155,7 @@
             '     },'
             '}')
 
-        self.assertRaisesRegexp(r'In section "CC_RULES", the following definitions are not used and should be removed: WatchList1',
+        self.assertRaisesRegexp(Exception, r'In section "CC_RULES", the following definitions are not used and should be removed: WatchList1',
                                 self._watch_list_parser.parse, watch_list)
 
     def test_message_rule_with_undefined_defintion(self):
@@ -165,7 +166,7 @@
             '     },'
             '}')
 
-        self.assertRaisesRegexp(r'In section "MESSAGE_RULES", the following definitions are not used and should be removed: WatchList1',
+        self.assertRaisesRegexp(Exception, r'In section "MESSAGE_RULES", the following definitions are not used and should be removed: WatchList1',
                                 self._watch_list_parser.parse, watch_list)
 
     def test_cc_rule_with_undefined_defintion_with_suggestion(self):
@@ -184,6 +185,6 @@
             '     },'
             '}')
 
-        self.assertRaisesRegexp(r'In section "CC_RULES", the following definitions are not used and should be removed: WatchList\s*'
+        self.assertRaisesRegexp(Exception, r'In section "CC_RULES", the following definitions are not used and should be removed: WatchList\s*'
                                 r'Perhaps it should be WatchList1\.',
                                 self._watch_list_parser.parse, watch_list)

Modified: trunk/Tools/Scripts/webkitpy/common/webkitunittest.py (97170 => 97171)


--- trunk/Tools/Scripts/webkitpy/common/webkitunittest.py	2011-10-11 19:56:28 UTC (rev 97170)
+++ trunk/Tools/Scripts/webkitpy/common/webkitunittest.py	2011-10-11 20:21:23 UTC (rev 97171)
@@ -34,13 +34,16 @@
 
 class TestCase(unittest.TestCase):
     def setUp(self):
-        # FIXME: Only do this for versions of Python before 2.7.
-        self.assertRaisesRegexp = self._assertRaisesRegexp
+        # For versions of Python before 2.7.
+        if not 'assertRaisesRegexp' in dir(self):
+            self.assertRaisesRegexp = self._assertRaisesRegexp
 
-    def _assertRaisesRegexp(self, regex_message, callable, *args):
+    def _assertRaisesRegexp(self, expected_exception, regex_message, callable, *args):
         try:
             callable(*args)
             self.assertTrue(False, 'No assert raised.')
         except Exception, exception:
+            self.assertTrue(issubclass(exception.__class__, expected_exception),
+                            'Exception type was unexpected.')
             self.assertTrue(re.match(regex_message, exception.__str__()),
                             'Expected regex "%s"\nGot "%s"' % (regex_message, exception.__str__()))

Modified: trunk/Tools/Scripts/webkitpy/tool/commands/applywatchlistlocal_unittest.py (97170 => 97171)


--- trunk/Tools/Scripts/webkitpy/tool/commands/applywatchlistlocal_unittest.py	2011-10-11 19:56:28 UTC (rev 97170)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/applywatchlistlocal_unittest.py	2011-10-11 20:21:23 UTC (rev 97171)
@@ -47,4 +47,4 @@
         self.assert_execute_outputs(ApplyWatchListLocal(), ['50002'], expected_stderr=expected_stderr)
 
     def test_args_parsing_with_two_bugs(self):
-        self._assertRaisesRegexp('Too many arguments given: 1234 5678', self.assert_execute_outputs, ApplyWatchListLocal(), ['1234', '5678'])
+        self._assertRaisesRegexp(Exception, 'Too many arguments given: 1234 5678', self.assert_execute_outputs, ApplyWatchListLocal(), ['1234', '5678'])
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to