File dae602d37493bae239e0e8db5b3dabafebfd59db.patch of Package python-pexpect.30661

From dae602d37493bae239e0e8db5b3dabafebfd59db Mon Sep 17 00:00:00 2001
From: Scott Talbert <swt@techie.net>
Date: Wed, 1 Feb 2023 22:38:53 -0500
Subject: [PATCH] tests: Replace assertRaisesRegexp with assertRaisesRegex

unittest.TestCase.assertRaisesRegexp was deprecated in Python 3.2 and is
removed in Python 3.12.
---
 tests/PexpectTestCase.py  | 2 +-
 tests/test_expect.py      | 8 ++++----
 tests/test_misc.py        | 4 ++--
 tests/test_popen_spawn.py | 8 ++++----
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/tests/PexpectTestCase.py b/tests/PexpectTestCase.py
index 307437ef..5d7a1684 100644
--- a/tests/PexpectTestCase.py
+++ b/tests/PexpectTestCase.py
@@ -97,7 +97,7 @@ def assertRaises(self, excClass):
                 raise AssertionError("%s was not raised" % excClass)
 
         @contextlib.contextmanager
-        def assertRaisesRegexp(self, excClass, pattern):
+        def assertRaisesRegex(self, excClass, pattern):
             import re
             try:
                 yield
diff --git a/tests/test_expect.py b/tests/test_expect.py
index 5e54d65c..be6078c4 100755
--- a/tests/test_expect.py
+++ b/tests/test_expect.py
@@ -643,13 +643,13 @@ def test_greed_exact(self):
 
     def test_bad_arg(self):
         p = pexpect.spawn('cat')
-        with self.assertRaisesRegexp(TypeError, '.*must be one of'):
+        with self.assertRaisesRegex(TypeError, '.*must be one of'):
             p.expect(1)
-        with self.assertRaisesRegexp(TypeError, '.*must be one of'):
+        with self.assertRaisesRegex(TypeError, '.*must be one of'):
             p.expect([1, b'2'])
-        with self.assertRaisesRegexp(TypeError, '.*must be one of'):
+        with self.assertRaisesRegex(TypeError, '.*must be one of'):
             p.expect_exact(1)
-        with self.assertRaisesRegexp(TypeError, '.*must be one of'):
+        with self.assertRaisesRegex(TypeError, '.*must be one of'):
             p.expect_exact([1, b'2'])
 
     def test_timeout_none(self):
diff --git a/tests/test_misc.py b/tests/test_misc.py
index 77847593..3dc2b6ec 100755
--- a/tests/test_misc.py
+++ b/tests/test_misc.py
@@ -214,7 +214,7 @@ def test_bad_child_pid(self):
         # Force an invalid state to test isalive
         child.ptyproc.terminated = 0
         try:
-            with self.assertRaisesRegexp(pexpect.ExceptionPexpect,
+            with self.assertRaisesRegex(pexpect.ExceptionPexpect,
                                          ".*" + expect_errmsg):
                 child.isalive()
         finally:
@@ -224,7 +224,7 @@ def test_bad_child_pid(self):
     def test_bad_arguments_suggest_fdpsawn(self):
         " assert custom exception for spawn(int). "
         expect_errmsg = "maybe you want to use fdpexpect.fdspawn"
-        with self.assertRaisesRegexp(pexpect.ExceptionPexpect,
+        with self.assertRaisesRegex(pexpect.ExceptionPexpect,
                                      ".*" + expect_errmsg):
             pexpect.spawn(1)
 
diff --git a/tests/test_popen_spawn.py b/tests/test_popen_spawn.py
index fca7493d..10d70326 100644
--- a/tests/test_popen_spawn.py
+++ b/tests/test_popen_spawn.py
@@ -110,13 +110,13 @@ def test_unexpected_eof(self):
 
     def test_bad_arg(self):
         p = PopenSpawn('cat')
-        with self.assertRaisesRegexp(TypeError, '.*must be one of'):
+        with self.assertRaisesRegex(TypeError, '.*must be one of'):
             p.expect(1)
-        with self.assertRaisesRegexp(TypeError, '.*must be one of'):
+        with self.assertRaisesRegex(TypeError, '.*must be one of'):
             p.expect([1, b'2'])
-        with self.assertRaisesRegexp(TypeError, '.*must be one of'):
+        with self.assertRaisesRegex(TypeError, '.*must be one of'):
             p.expect_exact(1)
-        with self.assertRaisesRegexp(TypeError, '.*must be one of'):
+        with self.assertRaisesRegex(TypeError, '.*must be one of'):
             p.expect_exact([1, b'2'])
 
     def test_timeout_none(self):
openSUSE Build Service is sponsored by