Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
a45e6d57
Commit
a45e6d57
authored
Jun 21, 2010
by
Thomas Heller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for problems reported in issue 8959.
parent
f180099e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
+35
-0
Lib/ctypes/test/test_callbacks.py
Lib/ctypes/test/test_callbacks.py
+35
-0
No files found.
Lib/ctypes/test/test_callbacks.py
View file @
a45e6d57
...
...
@@ -172,6 +172,41 @@ class SampleCallbacksTestCase(unittest.TestCase):
self
.
assertLess
(
diff
,
0.01
,
"%s not less than 0.01"
%
diff
)
def
test_issue_8959_a
(
self
):
from
ctypes.util
import
find_library
libc_path
=
find_library
(
"c"
)
if
not
libc_path
:
return
# cannot test
libc
=
CDLL
(
libc_path
)
@
CFUNCTYPE
(
c_int
,
POINTER
(
c_int
),
POINTER
(
c_int
))
def
cmp_func
(
a
,
b
):
return
a
[
0
]
-
b
[
0
]
array
=
(
c_int
*
5
)(
5
,
1
,
99
,
7
,
33
)
libc
.
qsort
(
array
,
len
(
array
),
sizeof
(
c_int
),
cmp_func
)
self
.
assertEqual
(
array
[:],
[
1
,
5
,
7
,
33
,
99
])
try
:
WINFUNCTYPE
except
NameError
:
pass
else
:
def
test_issue_8959_b
(
self
):
from
ctypes.wintypes
import
BOOL
,
HWND
,
LPARAM
global
windowCount
windowCount
=
0
@
WINFUNCTYPE
(
BOOL
,
HWND
,
LPARAM
)
def
EnumWindowsCallbackFunc
(
hwnd
,
lParam
):
global
windowCount
windowCount
+=
1
return
True
#Allow windows to keep enumerating
windll
.
user32
.
EnumWindows
(
EnumWindowsCallbackFunc
,
0
)
self
.
assertFalse
(
windowCount
==
0
)
################################################################
if
__name__
==
'__main__'
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment