Commits

Ronald Oussoren committed 6fd4724

commit a new test file

Comments (0)

Files changed (1)

pyobjc-core/PyObjCTest/test_pointer_compat.py

+from PyObjCTools.TestSupport import *
+import objc
+import ctypes
+
+
+class TestProxySupport (TestCase):
+    def test_cobject_roundtrip(self):
+        arr = objc.lookUpClass('NSArray').array()
+
+        p = arr.__cobject__()
+        self.assertEqual(type(p).__name__, "PyCapsule")
+        self.assertIn("objc.__object__", repr(p))
+        # Note: 
+
+        v = objc.objc_object(cobject=p)
+        self.assertIs(v, arr)
+
+    def test_voidp_roundtrip(self):
+        arr = objc.lookUpClass('NSArray').array()
+
+        p = arr.__c_void_p__()
+        self.assertIsInstance(p, ctypes.c_void_p)
+        self.assertEqual(p.value, objc.pyobjc_id(arr))
+
+        v = objc.objc_object(c_void_p=p)
+        self.assertIs(v, arr)
+
+    @expectedFailure
+    def test_missing(self):
+        # Add tests simular to the ones above, but
+        # with objects created outside of PyObjC
+        self.fail()
+
+if __name__ == "__main__":
+    main()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.