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

Side by Side Diff: Lib/ctypes/test/test_values.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_unicode.py ('k') | Lib/ctypes/test/test_win32.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 """ 1 """
2 A testcase which accesses *values* in a dll. 2 A testcase which accesses *values* in a dll.
3 """ 3 """
4 4
5 import os
5 import unittest 6 import unittest
6 import sys 7 import sys
7 from ctypes import * 8 from ctypes import *
8 9
9 import _ctypes_test 10 import _ctypes_test
10 11
11 class ValuesTestCase(unittest.TestCase): 12 class ValuesTestCase(unittest.TestCase):
12 13
13 def test_an_integer(self): 14 def test_an_integer(self):
14 # This test checks and changes an integer stored inside the 15 # This test checks and changes an integer stored inside the
15 # _ctypes_test dll/shared lib. 16 # _ctypes_test dll/shared lib.
16 ctdll = CDLL(_ctypes_test.__file__) 17 ctdll = CDLL(getattr(_ctypes_test, '__file__', os.environ['TEST_EXECUTAB LE']))
17 an_integer = c_int.in_dll(ctdll, "an_integer") 18 an_integer = c_int.in_dll(ctdll, "an_integer")
18 x = an_integer.value 19 x = an_integer.value
19 self.assertEqual(x, ctdll.get_an_integer()) 20 self.assertEqual(x, ctdll.get_an_integer())
20 an_integer.value *= 2 21 an_integer.value *= 2
21 self.assertEqual(x*2, ctdll.get_an_integer()) 22 self.assertEqual(x*2, ctdll.get_an_integer())
22 # To avoid test failures when this test is repeated several 23 # To avoid test failures when this test is repeated several
23 # times the original value must be restored 24 # times the original value must be restored
24 an_integer.value = x 25 an_integer.value = x
25 self.assertEqual(x, ctdll.get_an_integer()) 26 self.assertEqual(x, ctdll.get_an_integer())
26 27
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 91
91 from ctypes import _pointer_type_cache 92 from ctypes import _pointer_type_cache
92 del _pointer_type_cache[struct_frozen] 93 del _pointer_type_cache[struct_frozen]
93 94
94 def test_undefined(self): 95 def test_undefined(self):
95 self.assertRaises(ValueError, c_int.in_dll, pythonapi, 96 self.assertRaises(ValueError, c_int.in_dll, pythonapi,
96 "Undefined_Symbol") 97 "Undefined_Symbol")
97 98
98 if __name__ == '__main__': 99 if __name__ == '__main__':
99 unittest.main() 100 unittest.main()
OLDNEW
« no previous file with comments | « Lib/ctypes/test/test_unicode.py ('k') | Lib/ctypes/test/test_win32.py » ('j') | no next file with comments »

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