source: titan/mediathek/localhoster/lib/python2.7/ctypes/test/test_repr.py @ 40094

Last change on this file since 40094 was 40094, checked in by obi, 7 years ago

tithek add yoztube-dl support

File size: 839 bytes
Line 
1from ctypes import *
2import unittest
3
4subclasses = []
5for base in [c_byte, c_short, c_int, c_long, c_longlong,
6        c_ubyte, c_ushort, c_uint, c_ulong, c_ulonglong,
7        c_float, c_double, c_longdouble, c_bool]:
8    class X(base):
9        pass
10    subclasses.append(X)
11
12class X(c_char):
13    pass
14
15# This test checks if the __repr__ is correct for subclasses of simple types
16
17class ReprTest(unittest.TestCase):
18    def test_numbers(self):
19        for typ in subclasses:
20            base = typ.__bases__[0]
21            self.assertTrue(repr(base(42)).startswith(base.__name__))
22            self.assertEqual("<X object at", repr(typ(42))[:12])
23
24    def test_char(self):
25        self.assertEqual("c_char('x')", repr(c_char('x')))
26        self.assertEqual("<X object at", repr(X('x'))[:12])
27
28if __name__ == "__main__":
29    unittest.main()
Note: See TracBrowser for help on using the repository browser.