OLD | NEW |
1 import array | 1 import array |
2 import unittest | 2 import unittest |
3 import struct | 3 import struct |
4 import warnings | 4 import warnings |
5 warnings.filterwarnings("ignore", "struct integer overflow masking is deprecated
", | 5 warnings.filterwarnings("ignore", "struct integer overflow masking is deprecated
", |
6 DeprecationWarning) | 6 DeprecationWarning) |
7 | 7 |
8 from functools import wraps | 8 from functools import wraps |
9 from test.test_support import TestFailed, verbose, run_unittest | 9 from test.test_support import TestFailed, verbose, run_unittest |
10 | 10 |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 220 |
221 class IntTester(unittest.TestCase): | 221 class IntTester(unittest.TestCase): |
222 | 222 |
223 # XXX Most std integer modes fail to test for out-of-range. | 223 # XXX Most std integer modes fail to test for out-of-range. |
224 # The "i" and "l" codes appear to range-check OK on 32-bit boxes, bu
t | 224 # The "i" and "l" codes appear to range-check OK on 32-bit boxes, bu
t |
225 # fail to check correctly on some 64-bit ones (Tru64 Unix + Compaq C | 225 # fail to check correctly on some 64-bit ones (Tru64 Unix + Compaq C |
226 # reported by Mark Favas). | 226 # reported by Mark Favas). |
227 BUGGY_RANGE_CHECK = "bBhHiIlL" | 227 BUGGY_RANGE_CHECK = "bBhHiIlL" |
228 | 228 |
229 def __init__(self, formatpair, bytesize): | 229 def __init__(self, formatpair, bytesize): |
| 230 super(IntTester, self).__init__(methodName='test_one') |
230 self.assertEqual(len(formatpair), 2) | 231 self.assertEqual(len(formatpair), 2) |
231 self.formatpair = formatpair | 232 self.formatpair = formatpair |
232 for direction in "<>!=": | 233 for direction in "<>!=": |
233 for code in formatpair: | 234 for code in formatpair: |
234 format = direction + code | 235 format = direction + code |
235 self.assertEqual(struct.calcsize(format), bytesize) | 236 self.assertEqual(struct.calcsize(format), bytesize) |
236 self.bytesize = bytesize | 237 self.bytesize = bytesize |
237 self.bitsize = bytesize * 8 | 238 self.bitsize = bytesize * 8 |
238 self.signed_code, self.unsigned_code = formatpair | 239 self.signed_code, self.unsigned_code = formatpair |
239 self.unsigned_min = 0 | 240 self.unsigned_min = 0 |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 def test_crasher(self): | 582 def test_crasher(self): |
582 self.assertRaises(MemoryError, struct.pack, "357913941c", "a") | 583 self.assertRaises(MemoryError, struct.pack, "357913941c", "a") |
583 | 584 |
584 | 585 |
585 | 586 |
586 def test_main(): | 587 def test_main(): |
587 run_unittest(StructTest) | 588 run_unittest(StructTest) |
588 | 589 |
589 if __name__ == '__main__': | 590 if __name__ == '__main__': |
590 test_main() | 591 test_main() |
OLD | NEW |