mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
gh-71339: Use new assertion methods in test_ctypes (GH-129054)
This commit is contained in:
parent
df66ff14b4
commit
38c3cf6320
3 changed files with 12 additions and 12 deletions
|
@ -54,9 +54,9 @@ class PyCSimpleTypeAsMetaclassTest(unittest.TestCase):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
self.assertIsInstance(POINTER(Sub2), p_meta)
|
self.assertIsInstance(POINTER(Sub2), p_meta)
|
||||||
self.assertTrue(issubclass(POINTER(Sub2), Sub2))
|
self.assertIsSubclass(POINTER(Sub2), Sub2)
|
||||||
self.assertTrue(issubclass(POINTER(Sub2), POINTER(Sub)))
|
self.assertIsSubclass(POINTER(Sub2), POINTER(Sub))
|
||||||
self.assertTrue(issubclass(POINTER(Sub), POINTER(CtBase)))
|
self.assertIsSubclass(POINTER(Sub), POINTER(CtBase))
|
||||||
|
|
||||||
def test_creating_pointer_in_dunder_new_2(self):
|
def test_creating_pointer_in_dunder_new_2(self):
|
||||||
# A simpler variant of the above, used in `CoClass` of the `comtypes`
|
# A simpler variant of the above, used in `CoClass` of the `comtypes`
|
||||||
|
@ -84,7 +84,7 @@ class PyCSimpleTypeAsMetaclassTest(unittest.TestCase):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
self.assertIsInstance(POINTER(Sub), p_meta)
|
self.assertIsInstance(POINTER(Sub), p_meta)
|
||||||
self.assertTrue(issubclass(POINTER(Sub), Sub))
|
self.assertIsSubclass(POINTER(Sub), Sub)
|
||||||
|
|
||||||
def test_creating_pointer_in_dunder_init_1(self):
|
def test_creating_pointer_in_dunder_init_1(self):
|
||||||
class ct_meta(type):
|
class ct_meta(type):
|
||||||
|
@ -120,9 +120,9 @@ class PyCSimpleTypeAsMetaclassTest(unittest.TestCase):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
self.assertIsInstance(POINTER(Sub2), p_meta)
|
self.assertIsInstance(POINTER(Sub2), p_meta)
|
||||||
self.assertTrue(issubclass(POINTER(Sub2), Sub2))
|
self.assertIsSubclass(POINTER(Sub2), Sub2)
|
||||||
self.assertTrue(issubclass(POINTER(Sub2), POINTER(Sub)))
|
self.assertIsSubclass(POINTER(Sub2), POINTER(Sub))
|
||||||
self.assertTrue(issubclass(POINTER(Sub), POINTER(CtBase)))
|
self.assertIsSubclass(POINTER(Sub), POINTER(CtBase))
|
||||||
|
|
||||||
def test_creating_pointer_in_dunder_init_2(self):
|
def test_creating_pointer_in_dunder_init_2(self):
|
||||||
class ct_meta(type):
|
class ct_meta(type):
|
||||||
|
@ -149,4 +149,4 @@ class PyCSimpleTypeAsMetaclassTest(unittest.TestCase):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
self.assertIsInstance(POINTER(Sub), p_meta)
|
self.assertIsInstance(POINTER(Sub), p_meta)
|
||||||
self.assertTrue(issubclass(POINTER(Sub), Sub))
|
self.assertIsSubclass(POINTER(Sub), Sub)
|
||||||
|
|
|
@ -135,7 +135,7 @@ class LoaderTest(unittest.TestCase):
|
||||||
'test specific to Windows')
|
'test specific to Windows')
|
||||||
def test_load_hasattr(self):
|
def test_load_hasattr(self):
|
||||||
# bpo-34816: shouldn't raise OSError
|
# bpo-34816: shouldn't raise OSError
|
||||||
self.assertFalse(hasattr(ctypes.windll, 'test'))
|
self.assertNotHasAttr(ctypes.windll, 'test')
|
||||||
|
|
||||||
@unittest.skipUnless(os.name == "nt",
|
@unittest.skipUnless(os.name == "nt",
|
||||||
'test specific to Windows')
|
'test specific to Windows')
|
||||||
|
|
|
@ -22,12 +22,12 @@ class ReprTest(unittest.TestCase):
|
||||||
def test_numbers(self):
|
def test_numbers(self):
|
||||||
for typ in subclasses:
|
for typ in subclasses:
|
||||||
base = typ.__bases__[0]
|
base = typ.__bases__[0]
|
||||||
self.assertTrue(repr(base(42)).startswith(base.__name__))
|
self.assertStartsWith(repr(base(42)), base.__name__)
|
||||||
self.assertEqual("<X object at", repr(typ(42))[:12])
|
self.assertStartsWith(repr(typ(42)), "<X object at")
|
||||||
|
|
||||||
def test_char(self):
|
def test_char(self):
|
||||||
self.assertEqual("c_char(b'x')", repr(c_char(b'x')))
|
self.assertEqual("c_char(b'x')", repr(c_char(b'x')))
|
||||||
self.assertEqual("<X object at", repr(X(b'x'))[:12])
|
self.assertStartsWith(repr(X(b'x')), "<X object at")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue