ยปCore Development>Code coverage>Lib/ctypes/test/test_checkretval.py

Python code coverage for Lib/ctypes/test/test_checkretval.py

#countcontent
1n/aimport unittest
2n/a
3n/afrom ctypes import *
4n/afrom ctypes.test import need_symbol
5n/a
6n/aclass CHECKED(c_int):
7n/a def _check_retval_(value):
8n/a # Receives a CHECKED instance.
9n/a return str(value.value)
10n/a _check_retval_ = staticmethod(_check_retval_)
11n/a
12n/aclass Test(unittest.TestCase):
13n/a
14n/a def test_checkretval(self):
15n/a
16n/a import _ctypes_test
17n/a dll = CDLL(_ctypes_test.__file__)
18n/a self.assertEqual(42, dll._testfunc_p_p(42))
19n/a
20n/a dll._testfunc_p_p.restype = CHECKED
21n/a self.assertEqual("42", dll._testfunc_p_p(42))
22n/a
23n/a dll._testfunc_p_p.restype = None
24n/a self.assertEqual(None, dll._testfunc_p_p(42))
25n/a
26n/a del dll._testfunc_p_p.restype
27n/a self.assertEqual(42, dll._testfunc_p_p(42))
28n/a
29n/a @need_symbol('oledll')
30n/a def test_oledll(self):
31n/a self.assertRaises(OSError,
32n/a oledll.oleaut32.CreateTypeLib2,
33n/a 0, None, None)
34n/a
35n/aif __name__ == "__main__":
36n/a unittest.main()