From: Nikita Sobolev Date: Tue, 23 Nov 2021 11:12:13 +0000 (+0300) Subject: bpo-45878: convert `try/except` to `self.assertRaises` in `Lib/ctypes/test/test_funct... X-Git-Tag: v3.11.0a3~155 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b48ac6fe38b2fca9963b097c04cdecfc6083104e;p=thirdparty%2FPython%2Fcpython.git bpo-45878: convert `try/except` to `self.assertRaises` in `Lib/ctypes/test/test_functions.py` (GH-29721) --- diff --git a/Lib/ctypes/test/test_functions.py b/Lib/ctypes/test/test_functions.py index c5456ba107ae..f9e92e1cc6b0 100644 --- a/Lib/ctypes/test/test_functions.py +++ b/Lib/ctypes/test/test_functions.py @@ -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 index 000000000000..fca90ef46981 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2021-11-23-12-36-21.bpo-45878.eOs_Mp.rst @@ -0,0 +1,2 @@ +Test ``Lib/ctypes/test/test_functions.py::test_mro`` now uses +``self.assertRaises`` instead of ``try/except``.