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

Commit 38c3cf6

Browse filesBrowse files
gh-71339: Use new assertion methods in test_ctypes (GH-129054)
1 parent df66ff1 commit 38c3cf6
Copy full SHA for 38c3cf6

File tree

Expand file treeCollapse file tree

3 files changed

+12
-12
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+12
-12
lines changed

‎Lib/test/test_ctypes/test_c_simple_type_meta.py

Copy file name to clipboardExpand all lines: Lib/test/test_ctypes/test_c_simple_type_meta.py
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ class Sub2(Sub):
5454
pass
5555

5656
self.assertIsInstance(POINTER(Sub2), p_meta)
57-
self.assertTrue(issubclass(POINTER(Sub2), Sub2))
58-
self.assertTrue(issubclass(POINTER(Sub2), POINTER(Sub)))
59-
self.assertTrue(issubclass(POINTER(Sub), POINTER(CtBase)))
57+
self.assertIsSubclass(POINTER(Sub2), Sub2)
58+
self.assertIsSubclass(POINTER(Sub2), POINTER(Sub))
59+
self.assertIsSubclass(POINTER(Sub), POINTER(CtBase))
6060

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

8686
self.assertIsInstance(POINTER(Sub), p_meta)
87-
self.assertTrue(issubclass(POINTER(Sub), Sub))
87+
self.assertIsSubclass(POINTER(Sub), Sub)
8888

8989
def test_creating_pointer_in_dunder_init_1(self):
9090
class ct_meta(type):
@@ -120,9 +120,9 @@ class Sub2(Sub):
120120
pass
121121

122122
self.assertIsInstance(POINTER(Sub2), p_meta)
123-
self.assertTrue(issubclass(POINTER(Sub2), Sub2))
124-
self.assertTrue(issubclass(POINTER(Sub2), POINTER(Sub)))
125-
self.assertTrue(issubclass(POINTER(Sub), POINTER(CtBase)))
123+
self.assertIsSubclass(POINTER(Sub2), Sub2)
124+
self.assertIsSubclass(POINTER(Sub2), POINTER(Sub))
125+
self.assertIsSubclass(POINTER(Sub), POINTER(CtBase))
126126

127127
def test_creating_pointer_in_dunder_init_2(self):
128128
class ct_meta(type):
@@ -149,4 +149,4 @@ class Sub(CtBase):
149149
pass
150150

151151
self.assertIsInstance(POINTER(Sub), p_meta)
152-
self.assertTrue(issubclass(POINTER(Sub), Sub))
152+
self.assertIsSubclass(POINTER(Sub), Sub)

‎Lib/test/test_ctypes/test_loading.py

Copy file name to clipboardExpand all lines: Lib/test/test_ctypes/test_loading.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def test_1703286_B(self):
135135
'test specific to Windows')
136136
def test_load_hasattr(self):
137137
# bpo-34816: shouldn't raise OSError
138-
self.assertFalse(hasattr(ctypes.windll, 'test'))
138+
self.assertNotHasAttr(ctypes.windll, 'test')
139139

140140
@unittest.skipUnless(os.name == "nt",
141141
'test specific to Windows')

‎Lib/test/test_ctypes/test_repr.py

Copy file name to clipboardExpand all lines: Lib/test/test_ctypes/test_repr.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ class ReprTest(unittest.TestCase):
2222
def test_numbers(self):
2323
for typ in subclasses:
2424
base = typ.__bases__[0]
25-
self.assertTrue(repr(base(42)).startswith(base.__name__))
26-
self.assertEqual("<X object at", repr(typ(42))[:12])
25+
self.assertStartsWith(repr(base(42)), base.__name__)
26+
self.assertStartsWith(repr(typ(42)), "<X object at")
2727

2828
def test_char(self):
2929
self.assertEqual("c_char(b'x')", repr(c_char(b'x')))
30-
self.assertEqual("<X object at", repr(X(b'x'))[:12])
30+
self.assertStartsWith(repr(X(b'x')), "<X object at")
3131

3232

3333
if __name__ == "__main__":

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.