Skip to content

Commit

Permalink
bpo-45878: convert try/except to self.assertRaises in `Lib/ctypes…
Browse files Browse the repository at this point in the history
…/test/test_functions.py` (pythonGH-29721) (pythonGH-29723)

(cherry picked from commit b48ac6f)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
  • Loading branch information
miss-islington and sobolevn authored Dec 24, 2021
1 parent d718764 commit 393ff04
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
18 changes: 4 additions & 14 deletions Lib/ctypes/test/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Test ``Lib/ctypes/test/test_functions.py::test_mro`` now uses
``self.assertRaises`` instead of ``try/except``.

0 comments on commit 393ff04

Please sign in to comment.