Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(122303)

Side by Side Diff: Lib/ctypes/test/test_checkretval.py

Issue 23670: Modifications to support iOS as a development platform
Patch Set: Created 3 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/ctypes/test/test_cfuncs.py ('k') | Lib/ctypes/test/test_funcptr.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import os
1 import unittest 2 import unittest
2 3
3 from ctypes import * 4 from ctypes import *
4 from ctypes.test import need_symbol 5 from ctypes.test import need_symbol
5 6
6 class CHECKED(c_int): 7 class CHECKED(c_int):
7 def _check_retval_(value): 8 def _check_retval_(value):
8 # Receives a CHECKED instance. 9 # Receives a CHECKED instance.
9 return str(value.value) 10 return str(value.value)
10 _check_retval_ = staticmethod(_check_retval_) 11 _check_retval_ = staticmethod(_check_retval_)
11 12
12 class Test(unittest.TestCase): 13 class Test(unittest.TestCase):
13 14
14 def test_checkretval(self): 15 def test_checkretval(self):
15 16
16 import _ctypes_test 17 import _ctypes_test
17 dll = CDLL(_ctypes_test.__file__) 18 dll = CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTABLE ']))
18 self.assertEqual(42, dll._testfunc_p_p(42)) 19 self.assertEqual(42, dll._testfunc_p_p(42))
19 20
20 dll._testfunc_p_p.restype = CHECKED 21 dll._testfunc_p_p.restype = CHECKED
21 self.assertEqual("42", dll._testfunc_p_p(42)) 22 self.assertEqual("42", dll._testfunc_p_p(42))
22 23
23 dll._testfunc_p_p.restype = None 24 dll._testfunc_p_p.restype = None
24 self.assertEqual(None, dll._testfunc_p_p(42)) 25 self.assertEqual(None, dll._testfunc_p_p(42))
25 26
26 del dll._testfunc_p_p.restype 27 del dll._testfunc_p_p.restype
27 self.assertEqual(42, dll._testfunc_p_p(42)) 28 self.assertEqual(42, dll._testfunc_p_p(42))
28 29
29 @need_symbol('oledll') 30 @need_symbol('oledll')
30 def test_oledll(self): 31 def test_oledll(self):
31 self.assertRaises(OSError, 32 self.assertRaises(OSError,
32 oledll.oleaut32.CreateTypeLib2, 33 oledll.oleaut32.CreateTypeLib2,
33 0, None, None) 34 0, None, None)
34 35
35 if __name__ == "__main__": 36 if __name__ == "__main__":
36 unittest.main() 37 unittest.main()
OLDNEW
« no previous file with comments | « Lib/ctypes/test/test_cfuncs.py ('k') | Lib/ctypes/test/test_funcptr.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+