[Python-checkins] r82127 - python/trunk/Lib/ctypes/test/test_callbacks.py
R. David Murray
rdmurray at bitdance.com
Mon Jun 28 16:45:36 CEST 2010
On Mon, 21 Jun 2010 17:01:18 +0200, thomas.heller <python-checkins at python.org> wrote:
> Author: thomas.heller
> Date: Mon Jun 21 17:01:18 2010
> New Revision: 82127
>
> Log:
> Add tests for problems reported in issue 8959.
>
>
> Modified:
> python/trunk/Lib/ctypes/test/test_callbacks.py
>
> Modified: python/trunk/Lib/ctypes/test/test_callbacks.py
> ==============================================================================
> --- python/trunk/Lib/ctypes/test/test_callbacks.py (original)
> +++ python/trunk/Lib/ctypes/test/test_callbacks.py Mon Jun 21 17:01:18 2010
> @@ -172,6 +172,41 @@
>
> 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
Seems like it might it be better to raise a unittest.SkipTest here instead of
just returning.
> + 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)
You could also use a skip decorator for this method.
These comments assume you aren't backporting the tests to 2.6.
--David
More information about the Python-checkins
mailing list