-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
gh-103092: Test _ctypes
type hierarchy and features
#113727
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
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
1d95bbc
add inheritance hierarchy and other tests for ctypes base types
aisk 6df089c
add tests for cfuncptr
aisk 81802ae
add tests for CField
aisk a8b4d32
add test for COMError
aisk e48efc3
add support.py to export ctypes hidden types
aisk 0cd6f88
change to check the type's mutablility by type.__flags__
aisk b031cc9
fix assert in support.py
aisk 1e7c064
change more test to check the type.__flags__
aisk d843763
Update Lib/test/test_ctypes/support.py
aisk 8636250
rename type flag symbol name
aisk 6a0676c
move CField to support.py
aisk 37aecd4
test the type flags with sub test
aisk 3ccb964
rename support.py to _support.py to avoid ambiguous when import
aisk 0ac92f0
align the import statement
aisk efd0d9f
Update Lib/test/test_ctypes/test_arrays.py
aisk 2660e86
refactor the type flags check
aisk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
add inheritance hierarchy and other tests for ctypes base types
- Loading branch information
commit 1d95bbcf95489cb3db0cac0018f3cbb3db024372
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import ctypes | ||
import sys | ||
import unittest | ||
import warnings | ||
from ctypes import Union | ||
|
||
|
||
UnionType = type(Union) | ||
# _CData is not exported to Python, so we have to access it from __base__. | ||
_CData = Union.__base__ | ||
|
||
|
||
class ArrayTestCase(unittest.TestCase): | ||
def test_inheritance_hierarchy(self): | ||
self.assertEqual(_CData.__name__, "_CData") | ||
self.assertEqual(Union.mro(), [Union, _CData, object]) | ||
|
||
self.assertEqual(UnionType.__name__, "UnionType") | ||
self.assertEqual(type(UnionType), type) | ||
|
||
def test_instantiation(self): | ||
with self.assertRaisesRegex(TypeError, "abstract class"): | ||
Union() | ||
|
||
UnionType("Foo", (Union,), {}) | ||
|
||
def test_immutability(self): | ||
Union.foo = "bar" | ||
erlend-aasland marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
msg = "cannot set 'foo' attribute of immutable type" | ||
with self.assertRaisesRegex(TypeError, msg): | ||
UnionType.foo = "bar" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.