Commit 7372e3c9 authored by Martin Pitt's avatar Martin Pitt
Browse files

tests: Do not use deprecated assertRaisesRegexp()

Use assertRaisesRegex() instead and provide 2.7 compatibility in
tests/runtests.py.
parent da210690
......@@ -34,6 +34,9 @@ if sys.version_info[:2] == (2, 6):
unittest.TestCase.assertGreater = assertGreater
unittest.TestCase.assertIsInstance = assertIsInstance
if sys.version_info[:2] == (2, 7):
unittest.TestCase.assertRaisesRegex = unittest.TestCase.assertRaisesRegexp
if '--help' in sys.argv:
print("Usage: ./runtests.py <testfiles>")
sys.exit(0)
......
......@@ -737,12 +737,12 @@ class TestPython3Signals(unittest.TestCase):
class TestSignalModuleLevelFunctions(unittest.TestCase):
@unittest.skipIf(sys.version_info < (2, 7), 'Requires Python >= 2.7')
def test_signal_list_ids_with_invalid_type(self):
with self.assertRaisesRegexp(TypeError, 'type must be instantiable or an interface.*'):
with self.assertRaisesRegex(TypeError, 'type must be instantiable or an interface.*'):
GObject.signal_list_ids(GObject.TYPE_INVALID)
@unittest.skipIf(sys.version_info < (2, 7), 'Requires Python >= 2.7')
def test_signal_list_ids(self):
with self.assertRaisesRegexp(TypeError, 'type must be instantiable or an interface.*'):
with self.assertRaisesRegex(TypeError, 'type must be instantiable or an interface.*'):
GObject.signal_list_ids(GObject.TYPE_INT)
ids = GObject.signal_list_ids(C)
......@@ -754,7 +754,7 @@ class TestSignalModuleLevelFunctions(unittest.TestCase):
@unittest.skipIf(sys.version_info < (2, 7), 'Requires Python >= 2.7')
def test_signal_lookup_with_invalid_type(self):
with self.assertRaisesRegexp(TypeError, 'type must be instantiable or an interface.*'):
with self.assertRaisesRegex(TypeError, 'type must be instantiable or an interface.*'):
GObject.signal_lookup('NOT_A_SIGNAL_NAME', GObject.TYPE_INVALID)
@unittest.skipIf(sys.version_info < (2, 7), 'Requires Python >= 2.7')
......@@ -763,7 +763,7 @@ class TestSignalModuleLevelFunctions(unittest.TestCase):
self.assertEqual(ids[0], GObject.signal_lookup('my_signal', C))
self.assertEqual(ids[0], GObject.signal_lookup('my-signal', C))
with self.assertRaisesRegexp(TypeError, 'type must be instantiable or an interface.*'):
with self.assertRaisesRegex(TypeError, 'type must be instantiable or an interface.*'):
GObject.signal_lookup('NOT_A_SIGNAL_NAME', GObject.TYPE_INT)
# Invalid signal names return 0 instead of raising
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment