diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2021-12-24 09:28:57 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-24 09:28:57 (GMT) |
commit | a9e0b2b49374df91c40fe409508cfcdc6332450e (patch) | |
tree | 7a3e55bc4cc33359fcf2de4f94b1854db31de704 | |
parent | 8005e22c9c71708ead0e5b16e55e005844c5131f (diff) | |
download | cpython-a9e0b2b49374df91c40fe409508cfcdc6332450e.zip cpython-a9e0b2b49374df91c40fe409508cfcdc6332450e.tar.gz cpython-a9e0b2b49374df91c40fe409508cfcdc6332450e.tar.bz2 |
bpo-45878: convert `try/except` to `self.assertRaises` in `Lib/ctypes/test/test_functions.py` (GH-29721) (GH-29748)
(cherry picked from commit b48ac6fe38b2fca9963b097c04cdecfc6083104e)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
-rw-r--r-- | Lib/ctypes/test/test_functions.py | 18 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Tests/2021-11-23-12-36-21.bpo-45878.eOs_Mp.rst | 2 |
2 files changed, 6 insertions, 14 deletions
diff --git a/Lib/ctypes/test/test_functions.py b/Lib/ctypes/test/test_functions.py index d3c6536..bdb044e 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 0000000..fca90ef --- /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``. |