Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-71339: Use new assertion methods in test_ctypes #129054

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions 16 Lib/test/test_ctypes/test_c_simple_type_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ class Sub2(Sub):
pass

self.assertIsInstance(POINTER(Sub2), p_meta)
self.assertTrue(issubclass(POINTER(Sub2), Sub2))
self.assertTrue(issubclass(POINTER(Sub2), POINTER(Sub)))
self.assertTrue(issubclass(POINTER(Sub), POINTER(CtBase)))
self.assertIsSubclass(POINTER(Sub2), Sub2)
self.assertIsSubclass(POINTER(Sub2), POINTER(Sub))
self.assertIsSubclass(POINTER(Sub), POINTER(CtBase))

def test_creating_pointer_in_dunder_new_2(self):
# A simpler variant of the above, used in `CoClass` of the `comtypes`
Expand Down Expand Up @@ -84,7 +84,7 @@ class Sub(CtBase):
pass

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):
class ct_meta(type):
Expand Down Expand Up @@ -120,9 +120,9 @@ class Sub2(Sub):
pass

self.assertIsInstance(POINTER(Sub2), p_meta)
self.assertTrue(issubclass(POINTER(Sub2), Sub2))
self.assertTrue(issubclass(POINTER(Sub2), POINTER(Sub)))
self.assertTrue(issubclass(POINTER(Sub), POINTER(CtBase)))
self.assertIsSubclass(POINTER(Sub2), Sub2)
self.assertIsSubclass(POINTER(Sub2), POINTER(Sub))
self.assertIsSubclass(POINTER(Sub), POINTER(CtBase))

def test_creating_pointer_in_dunder_init_2(self):
class ct_meta(type):
Expand All @@ -149,4 +149,4 @@ class Sub(CtBase):
pass

self.assertIsInstance(POINTER(Sub), p_meta)
self.assertTrue(issubclass(POINTER(Sub), Sub))
self.assertIsSubclass(POINTER(Sub), Sub)
2 changes: 1 addition & 1 deletion 2 Lib/test/test_ctypes/test_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def test_1703286_B(self):
'test specific to Windows')
def test_load_hasattr(self):
# bpo-34816: shouldn't raise OSError
self.assertFalse(hasattr(ctypes.windll, 'test'))
self.assertNotHasAttr(ctypes.windll, 'test')

@unittest.skipUnless(os.name == "nt",
'test specific to Windows')
Expand Down
6 changes: 3 additions & 3 deletions 6 Lib/test/test_ctypes/test_repr.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ class ReprTest(unittest.TestCase):
def test_numbers(self):
for typ in subclasses:
base = typ.__bases__[0]
self.assertTrue(repr(base(42)).startswith(base.__name__))
self.assertEqual("<X object at", repr(typ(42))[:12])
self.assertStartsWith(repr(base(42)), base.__name__)
self.assertStartsWith(repr(typ(42)), "<X object at")

def test_char(self):
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__":
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.