(self)
| 1109 | plistlib.loads(b'bplist00' + data, fmt=plistlib.FMT_BINARY) |
| 1110 | |
| 1111 | def test_truncated_large_data(self): |
| 1112 | self.addCleanup(os_helper.unlink, os_helper.TESTFN) |
| 1113 | def check(data): |
| 1114 | with open(os_helper.TESTFN, 'wb') as f: |
| 1115 | f.write(data) |
| 1116 | # buffered file |
| 1117 | with open(os_helper.TESTFN, 'rb') as f: |
| 1118 | with self.assertRaises(plistlib.InvalidFileException): |
| 1119 | plistlib.load(f, fmt=plistlib.FMT_BINARY) |
| 1120 | # unbuffered file |
| 1121 | with open(os_helper.TESTFN, 'rb', buffering=0) as f: |
| 1122 | with self.assertRaises(plistlib.InvalidFileException): |
| 1123 | plistlib.load(f, fmt=plistlib.FMT_BINARY) |
| 1124 | for w in range(20, 64): |
| 1125 | s = 1 << w |
| 1126 | # data |
| 1127 | check(self.build(b'\x4f\x13' + s.to_bytes(8, 'big'))) |
| 1128 | # ascii string |
| 1129 | check(self.build(b'\x5f\x13' + s.to_bytes(8, 'big'))) |
| 1130 | # unicode string |
| 1131 | check(self.build(b'\x6f\x13' + s.to_bytes(8, 'big'))) |
| 1132 | # array |
| 1133 | check(self.build(b'\xaf\x13' + s.to_bytes(8, 'big'))) |
| 1134 | # dict |
| 1135 | check(self.build(b'\xdf\x13' + s.to_bytes(8, 'big'))) |
| 1136 | # number of objects |
| 1137 | check(b'bplist00' + struct.pack('>6xBBQQQ', 1, 1, s, 0, 8)) |
| 1138 | |
| 1139 | def test_load_aware_datetime(self): |
| 1140 | data = (b'bplist003B\x04>\xd0d\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00' |
nothing calls this directly
no test coverage detected