]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-45878: convert `try/except` to `self.assertRaises` in `Lib/ctypes/test/test_funct...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 24 Dec 2021 09:27:17 +0000 (01:27 -0800)
committerGitHub <noreply@github.com>
Fri, 24 Dec 2021 09:27:17 +0000 (11:27 +0200)
(cherry picked from commit b48ac6fe38b2fca9963b097c04cdecfc6083104e)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Lib/ctypes/test/test_functions.py
Misc/NEWS.d/next/Tests/2021-11-23-12-36-21.bpo-45878.eOs_Mp.rst [new file with mode: 0644]

index d3c6536f2766a768478cfb8a56b503a4ff5de34c..bdb044e594a2cf9f3ab2a05e818795b34f19c317 100644 (file)
@@ -35,34 +35,24 @@ class FunctionTestCase(unittest.TestCase):
         # wasn't checked, and it even crashed Python.
         # Found by Greg Chapman.
 
-        try:
+        with self.assertRaises(TypeError):
             class X(object, Array):
                 _length_ = 5
                 _type_ = "i"
-        except TypeError:
-            pass
-
 
         from _ctypes import _Pointer
-        try:
+        with self.assertRaises(TypeError):
             class X(object, _Pointer):
                 pass
-        except TypeError:
-            pass
 
         from _ctypes import _SimpleCData
-        try:
+        with self.assertRaises(TypeError):
             class X(object, _SimpleCData):
                 _type_ = "i"
-        except TypeError:
-            pass
 
-        try:
+        with self.assertRaises(TypeError):
             class X(object, Structure):
                 _fields_ = []
-        except TypeError:
-            pass
-
 
     @need_symbol('c_wchar')
     def test_wchar_parm(self):
diff --git a/Misc/NEWS.d/next/Tests/2021-11-23-12-36-21.bpo-45878.eOs_Mp.rst b/Misc/NEWS.d/next/Tests/2021-11-23-12-36-21.bpo-45878.eOs_Mp.rst
new file mode 100644 (file)
index 0000000..fca90ef
--- /dev/null
@@ -0,0 +1,2 @@
+Test ``Lib/ctypes/test/test_functions.py::test_mro`` now uses
+``self.assertRaises`` instead of ``try/except``.