Skip to content

Commit b48ac6f

Browse files
authored
bpo-45878: convert try/except to self.assertRaises in Lib/ctypes/test/test_functions.py (GH-29721)
1 parent 2c047f6 commit b48ac6f

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

Lib/ctypes/test/test_functions.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,34 +35,24 @@ def test_mro(self):
3535
# wasn't checked, and it even crashed Python.
3636
# Found by Greg Chapman.
3737

38-
try:
38+
with self.assertRaises(TypeError):
3939
class X(object, Array):
4040
_length_ = 5
4141
_type_ = "i"
42-
except TypeError:
43-
pass
44-
4542

4643
from _ctypes import _Pointer
47-
try:
44+
with self.assertRaises(TypeError):
4845
class X(object, _Pointer):
4946
pass
50-
except TypeError:
51-
pass
5247

5348
from _ctypes import _SimpleCData
54-
try:
49+
with self.assertRaises(TypeError):
5550
class X(object, _SimpleCData):
5651
_type_ = "i"
57-
except TypeError:
58-
pass
5952

60-
try:
53+
with self.assertRaises(TypeError):
6154
class X(object, Structure):
6255
_fields_ = []
63-
except TypeError:
64-
pass
65-
6656

6757
@need_symbol('c_wchar')
6858
def test_wchar_parm(self):
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Test ``Lib/ctypes/test/test_functions.py::test_mro`` now uses
2+
``self.assertRaises`` instead of ``try/except``.

0 commit comments

Comments
 (0)