[pygobject] tests: Do not use deprecated assertRaisesRegexp()
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] tests: Do not use deprecated assertRaisesRegexp()
- Date: Mon, 5 Nov 2012 09:15:53 +0000 (UTC)
commit 7372e3c9ecb8e836894c32975eab8c4107ba0b28
Author: Martin Pitt <martinpitt gnome org>
Date: Mon Nov 5 10:14:52 2012 +0100
tests: Do not use deprecated assertRaisesRegexp()
Use assertRaisesRegex() instead and provide 2.7 compatibility in
tests/runtests.py.
tests/runtests.py | 3 +++
tests/test_signal.py | 8 ++++----
2 files changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/tests/runtests.py b/tests/runtests.py
index c518fcc..9f3a7ec 100755
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -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)
diff --git a/tests/test_signal.py b/tests/test_signal.py
index f4396ce..e24f97f 100644
--- a/tests/test_signal.py
+++ b/tests/test_signal.py
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]