summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2020-11-06 16:02:43 +0100
committerChristoph Reiter <reiter.christoph@gmail.com>2020-11-07 09:09:19 +0100
commitebc0eed6f9838253ae6fcaa51695136611c98298 (patch)
tree9f0de5b8b923d12b4fbebde332682ec66410ebdb /tests
parentc464187c8b0b228a5299acaf35e74888982429b4 (diff)
downloadgobject-introspection-ebc0eed6f9838253ae6fcaa51695136611c98298.tar.gz
tests: Remove usage of some deprecated unittest methods
Diffstat (limited to 'tests')
-rw-r--r--tests/__init__.py4
-rw-r--r--tests/test_gi.py36
-rw-r--r--tests/test_gio.py4
-rw-r--r--tests/test_overrides_gdk.py4
-rw-r--r--tests/test_overrides_glib.py32
-rw-r--r--tests/test_overrides_gtk.py18
6 files changed, 47 insertions, 51 deletions
diff --git a/tests/__init__.py b/tests/__init__.py
index 34976673..e6dd333a 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -1,6 +1,5 @@
import os
import sys
-import unittest
import signal
import subprocess
import atexit
@@ -8,9 +7,6 @@ import warnings
def init_test_environ():
- # this was renamed in Python 3, provide backwards compatible name
- unittest.TestCase.assertRegexpMatches = unittest.TestCase.assertRegex
- unittest.TestCase.assertRaisesRegexp = unittest.TestCase.assertRaisesRegex
def dbus_launch_session():
if os.name == "nt" or sys.platform == "darwin":
diff --git a/tests/test_gi.py b/tests/test_gi.py
index 2cabe021..5e7d0e35 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -2248,22 +2248,22 @@ class TestStructure(unittest.TestCase):
self.assertRaises(TypeError, GIMarshallingTests.Union.method)
def test_repr(self):
- self.assertRegexpMatches(
+ self.assertRegex(
repr(GIMarshallingTests.PointerStruct()),
r"<GIMarshallingTests.PointerStruct object at 0x[^\s]+ "
r"\(void at 0x[^\s]+\)>")
- self.assertRegexpMatches(
+ self.assertRegex(
repr(GIMarshallingTests.SimpleStruct()),
r"<GIMarshallingTests.SimpleStruct object at 0x[^\s]+ "
r"\(void at 0x[^\s]+\)>")
- self.assertRegexpMatches(
+ self.assertRegex(
repr(GIMarshallingTests.Union()),
r"<GIMarshallingTests.Union object at 0x[^\s]+ "
r"\(GIMarshallingTestsUnion at 0x[^\s]+\)>")
- self.assertRegexpMatches(
+ self.assertRegex(
repr(GIMarshallingTests.BoxedStruct()),
r"<GIMarshallingTests.BoxedStruct object at 0x[^\s]+ "
r"\(GIMarshallingTestsBoxedStruct at 0x[^\s]+\)>")
@@ -2399,13 +2399,13 @@ class TestGObject(unittest.TestCase):
self.assertEqual(new_object.__grefcount__, 1)
def test_repr(self):
- self.assertRegexpMatches(
+ self.assertRegex(
repr(GIMarshallingTests.Object(int=42)),
r"<GIMarshallingTests.Object object at 0x[^\s]+ "
r"\(GIMarshallingTestsObject at 0x[^\s]+\)>")
def test_nongir_repr(self):
- self.assertRegexpMatches(
+ self.assertRegex(
repr(Gio.File.new_for_path("")),
r"<__gi__.GLocalFile object at 0x[^\s]+ "
r"\(GLocalFile at 0x[^\s]+\)>")
@@ -3208,7 +3208,7 @@ class TestDeprecation(unittest.TestCase):
self.assertEqual(len(warn), 3)
self.assertTrue(
issubclass(warn[0].category, PyGIDeprecationWarning))
- self.assertRegexpMatches(
+ self.assertRegex(
str(warn[0].message),
".*GLib.IO_STATUS_ERROR.*GLib.IOStatus.ERROR.*")
@@ -3244,8 +3244,8 @@ class TestDeprecation(unittest.TestCase):
fn(self, 1, 2, 3)
self.assertEqual(len(warn), 1)
self.assertTrue(issubclass(warn[0].category, PyGIDeprecationWarning))
- self.assertRegexpMatches(str(warn[0].message),
- '.*keyword.*a, b, c.*')
+ self.assertRegex(str(warn[0].message),
+ '.*keyword.*a, b, c.*')
def test_deprecated_init_no_keywords_out_of_order(self):
def init(self, **kwargs):
@@ -3257,8 +3257,8 @@ class TestDeprecation(unittest.TestCase):
fn(self, 2, 1, 3)
self.assertEqual(len(warn), 1)
self.assertTrue(issubclass(warn[0].category, PyGIDeprecationWarning))
- self.assertRegexpMatches(str(warn[0].message),
- '.*keyword.*b, a, c.*')
+ self.assertRegex(str(warn[0].message),
+ '.*keyword.*b, a, c.*')
def test_deprecated_init_ignored_keyword(self):
def init(self, **kwargs):
@@ -3272,8 +3272,8 @@ class TestDeprecation(unittest.TestCase):
fn(self, 1, 2, 3)
self.assertEqual(len(warn), 1)
self.assertTrue(issubclass(warn[0].category, PyGIDeprecationWarning))
- self.assertRegexpMatches(str(warn[0].message),
- '.*keyword.*a, b, c.*')
+ self.assertRegex(str(warn[0].message),
+ '.*keyword.*a, b, c.*')
def test_deprecated_init_with_aliases(self):
def init(self, **kwargs):
@@ -3288,8 +3288,8 @@ class TestDeprecation(unittest.TestCase):
fn(self, a=1, bb=2, cc=3)
self.assertEqual(len(warn), 1)
self.assertTrue(issubclass(warn[0].category, PyGIDeprecationWarning))
- self.assertRegexpMatches(str(warn[0].message),
- '.*keyword.*"bb, cc".*deprecated.*"b, c" respectively')
+ self.assertRegex(str(warn[0].message),
+ '.*keyword.*"bb, cc".*deprecated.*"b, c" respectively')
def test_deprecated_init_with_defaults(self):
def init(self, **kwargs):
@@ -3303,6 +3303,6 @@ class TestDeprecation(unittest.TestCase):
fn(self, a=1)
self.assertEqual(len(warn), 1)
self.assertTrue(issubclass(warn[0].category, PyGIDeprecationWarning))
- self.assertRegexpMatches(str(warn[0].message),
- '.*relying on deprecated non-standard defaults.*'
- 'explicitly use: b=2, c=3')
+ self.assertRegex(str(warn[0].message),
+ '.*relying on deprecated non-standard defaults.*'
+ 'explicitly use: b=2, c=3')
diff --git a/tests/test_gio.py b/tests/test_gio.py
index 3b812c44..07ee5068 100644
--- a/tests/test_gio.py
+++ b/tests/test_gio.py
@@ -50,8 +50,8 @@ class TestGio(unittest.TestCase):
Gio.VolumeMonitor()
self.assertEqual(len(warn), 1)
self.assertTrue(issubclass(warn[0].category, PyGIWarning))
- self.assertRegexpMatches(str(warn[0].message),
- '.*Gio\\.VolumeMonitor\\.get\\(\\).*')
+ self.assertRegex(str(warn[0].message),
+ '.*Gio\\.VolumeMonitor\\.get\\(\\).*')
class TestGSettings(unittest.TestCase):
diff --git a/tests/test_overrides_gdk.py b/tests/test_overrides_gdk.py
index 1788ef61..d9595710 100644
--- a/tests/test_overrides_gdk.py
+++ b/tests/test_overrides_gdk.py
@@ -227,8 +227,8 @@ class TestGdk(unittest.TestCase):
self.assertEqual(len(warn), 1)
self.assertTrue(issubclass(warn[0].category, PyGIDeprecationWarning))
- self.assertRegexpMatches(str(warn[0].message),
- '.*new_from_pixbuf.*')
+ self.assertRegex(str(warn[0].message),
+ '.*new_from_pixbuf.*')
self.assertRaises(ValueError, Gdk.Cursor, 1, 2, 3)
diff --git a/tests/test_overrides_glib.py b/tests/test_overrides_glib.py
index d8f1a6c0..08c41ae2 100644
--- a/tests/test_overrides_glib.py
+++ b/tests/test_overrides_glib.py
@@ -691,30 +691,30 @@ class TestGVariant(unittest.TestCase):
def test_parse_error_exceptions(self):
source_str = 'abc'
- self.assertRaisesRegexp(TypeError, 'Must be GLib.Error, not int',
- GLib.Variant.parse_error_print_context,
- 42, source_str)
+ self.assertRaisesRegex(TypeError, 'Must be GLib.Error, not int',
+ GLib.Variant.parse_error_print_context,
+ 42, source_str)
gerror = GLib.Error(message=42) # not a string
- self.assertRaisesRegexp(TypeError, ".*Must be string, not int.*",
- GLib.Variant.parse_error_print_context,
- gerror, source_str)
+ self.assertRaisesRegex(TypeError, ".*Must be string, not int.*",
+ GLib.Variant.parse_error_print_context,
+ gerror, source_str)
gerror = GLib.Error(domain=42) # not a string
- self.assertRaisesRegexp(TypeError, ".*Must be string, not int.*",
- GLib.Variant.parse_error_print_context,
- gerror, source_str)
+ self.assertRaisesRegex(TypeError, ".*Must be string, not int.*",
+ GLib.Variant.parse_error_print_context,
+ gerror, source_str)
gerror = GLib.Error(code='not an int')
- self.assertRaisesRegexp(TypeError, ".*Must be number, not str.*",
- GLib.Variant.parse_error_print_context,
- gerror, source_str)
+ self.assertRaisesRegex(TypeError, ".*Must be number, not str.*",
+ GLib.Variant.parse_error_print_context,
+ gerror, source_str)
gerror = GLib.Error(code=GLib.MAXUINT)
- self.assertRaisesRegexp(OverflowError,
- ".*not in range.*",
- GLib.Variant.parse_error_print_context,
- gerror, source_str)
+ self.assertRaisesRegex(OverflowError,
+ ".*not in range.*",
+ GLib.Variant.parse_error_print_context,
+ gerror, source_str)
class TestConstants(unittest.TestCase):
diff --git a/tests/test_overrides_gtk.py b/tests/test_overrides_gtk.py
index 30ad1d8b..091a6a24 100644
--- a/tests/test_overrides_gtk.py
+++ b/tests/test_overrides_gtk.py
@@ -403,8 +403,8 @@ class TestGtk(unittest.TestCase):
self.assertTrue(dialog.get_modal())
self.assertEqual(len(warn), 1)
self.assertTrue(issubclass(warn[0].category, PyGTKDeprecationWarning))
- self.assertRegexpMatches(str(warn[0].message),
- '.*flags.*modal.*')
+ self.assertRegex(str(warn[0].message),
+ '.*flags.*modal.*')
with warnings.catch_warnings(record=True) as warn:
warnings.simplefilter('always')
@@ -412,8 +412,8 @@ class TestGtk(unittest.TestCase):
self.assertTrue(dialog.get_destroy_with_parent())
self.assertEqual(len(warn), 1)
self.assertTrue(issubclass(warn[0].category, PyGTKDeprecationWarning))
- self.assertRegexpMatches(str(warn[0].message),
- '.*flags.*destroy_with_parent.*')
+ self.assertRegex(str(warn[0].message),
+ '.*flags.*destroy_with_parent.*')
def test_dialog_deprecation_stacklevels(self):
# Test warning levels are setup to give the correct filename for
@@ -425,7 +425,7 @@ class TestGtk(unittest.TestCase):
warnings.simplefilter('always')
Gtk.Dialog(flags=Gtk.DialogFlags.MODAL)
self.assertEqual(len(warn), 1)
- self.assertRegexpMatches(warn[0].filename, '.*test_overrides_gtk.*')
+ self.assertRegex(warn[0].filename, '.*test_overrides_gtk.*')
# Validate overridden base with overridden sub-class.
self.assertEqual(Gtk.MessageDialog, gi.overrides.Gtk.MessageDialog)
@@ -433,7 +433,7 @@ class TestGtk(unittest.TestCase):
warnings.simplefilter('always')
Gtk.MessageDialog(flags=Gtk.DialogFlags.MODAL)
self.assertEqual(len(warn), 1)
- self.assertRegexpMatches(warn[0].filename, '.*test_overrides_gtk.*')
+ self.assertRegex(warn[0].filename, '.*test_overrides_gtk.*')
# Validate overridden base with non-overridden sub-class.
self.assertEqual(Gtk.AboutDialog, gi.repository.Gtk.AboutDialog)
@@ -441,7 +441,7 @@ class TestGtk(unittest.TestCase):
warnings.simplefilter('always')
Gtk.AboutDialog(flags=Gtk.DialogFlags.MODAL)
self.assertEqual(len(warn), 1)
- self.assertRegexpMatches(warn[0].filename, '.*test_overrides_gtk.*')
+ self.assertRegex(warn[0].filename, '.*test_overrides_gtk.*')
def test_dialog_add_buttons(self):
# The overloaded "buttons" keyword gives a warning when attempting
@@ -452,8 +452,8 @@ class TestGtk(unittest.TestCase):
buttons=('test-button1', 1))
self.assertEqual(len(warn), 1)
self.assertTrue(issubclass(warn[0].category, PyGTKDeprecationWarning))
- self.assertRegexpMatches(str(warn[0].message),
- '.*ButtonsType.*add_buttons.*')
+ self.assertRegex(str(warn[0].message),
+ '.*ButtonsType.*add_buttons.*')
dialog.add_buttons('test-button2', 2, 'gtk-close', Gtk.ResponseType.CLOSE)
button = dialog.get_widget_for_response(1)