[Python-checkins] bpo-45878: convert `try/except` to `self.assertRaises` in `Lib/ctypes/test/test_functions.py` (GH-29721) (GH-29723)
serhiy-storchaka
webhook-mailer at python.org
Fri Dec 24 04:27:35 EST 2021
https://github.com/python/cpython/commit/393ff040281db818f2d6e0240919316f58f989a6
commit: 393ff040281db818f2d6e0240919316f58f989a6
branch: 3.9
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: serhiy-storchaka <storchaka at gmail.com>
date: 2021-12-24T11:27:17+02:00
summary:
bpo-45878: convert `try/except` to `self.assertRaises` in `Lib/ctypes/test/test_functions.py` (GH-29721) (GH-29723)
(cherry picked from commit b48ac6fe38b2fca9963b097c04cdecfc6083104e)
Co-authored-by: Nikita Sobolev <mail at sobolevn.me>
files:
A Misc/NEWS.d/next/Tests/2021-11-23-12-36-21.bpo-45878.eOs_Mp.rst
M Lib/ctypes/test/test_functions.py
diff --git a/Lib/ctypes/test/test_functions.py b/Lib/ctypes/test/test_functions.py
index d3c6536f2766a..bdb044e594a2c 100644
--- a/Lib/ctypes/test/test_functions.py
+++ b/Lib/ctypes/test/test_functions.py
@@ -35,34 +35,24 @@ def test_mro(self):
# 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 0000000000000..fca90ef46981b
--- /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``.
More information about the Python-checkins
mailing list