bpo-45878: convert try/except to self.assertRaises in Lib/ctypes/test/test_functions.py (GH-29721) (GH-29748)

(cherry picked from commit b48ac6fe38)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
Miss Islington (bot) 2021-12-24 01:28:57 -08:00 committed by GitHub
parent 8005e22c9c
commit a9e0b2b493
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 14 deletions

View file

@ -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):

View file

@ -0,0 +1,2 @@
Test ``Lib/ctypes/test/test_functions.py::test_mro`` now uses
``self.assertRaises`` instead of ``try/except``.