[pypy-commit] pypy default: Write a test for d4ed2c8ac9b1 (thanks lahwran for reporting it)

arigo noreply at buildbot.pypy.org
Tue Jun 5 09:58:00 CEST 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r55298:f772351ebc1b
Date: 2012-06-03 20:23 +0200
http://bitbucket.org/pypy/pypy/changeset/f772351ebc1b/

Log:	Write a test for d4ed2c8ac9b1 (thanks lahwran for reporting it)

diff --git a/pypy/module/test_lib_pypy/ctypes_tests/test_functions.py b/pypy/module/test_lib_pypy/ctypes_tests/test_functions.py
--- a/pypy/module/test_lib_pypy/ctypes_tests/test_functions.py
+++ b/pypy/module/test_lib_pypy/ctypes_tests/test_functions.py
@@ -484,6 +484,20 @@
         assert tf_b(-126) == -42
         assert tf_b._ptr is ptr
 
+    def test_custom_from_param(self):
+        class A(c_byte):
+            @classmethod
+            def from_param(cls, obj):
+                seen.append(obj)
+                return -126
+        tf_b = dll.tf_b
+        tf_b.restype = c_byte
+        tf_b.argtypes = (c_byte,)
+        tf_b.argtypes = [A]
+        seen = []
+        assert tf_b("yadda") == -42
+        assert seen == ["yadda"]
+
     def test_warnings(self):
         import warnings
         warnings.simplefilter("always")


More information about the pypy-commit mailing list