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'])