Changeset 391 for python/trunk/Lib/test/test_marshal.py
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Lib/test/test_marshal.py
r2 r391 130 130 def test_buffer(self): 131 131 for s in ["", "Andrè Previn", "abc", " "*10000]: 132 b = buffer(s) 132 with test_support.check_py3k_warnings(("buffer.. not supported", 133 DeprecationWarning)): 134 b = buffer(s) 133 135 new = marshal.loads(marshal.dumps(b)) 134 136 self.assertEqual(s, new) … … 190 192 new = marshal.loads(marshal.dumps(t)) 191 193 self.assertEqual(t, new) 192 self.assert _(isinstance(new, constructor))194 self.assertTrue(isinstance(new, constructor)) 193 195 self.assertNotEqual(id(t), id(new)) 194 196 marshal.dump(t, file(test_support.TESTFN, "wb")) … … 209 211 def test_version_argument(self): 210 212 # Python 2.4.0 crashes for any call to marshal.dumps(x, y) 211 self.assertEqual s(marshal.loads(marshal.dumps(5, 0)), 5)212 self.assertEqual s(marshal.loads(marshal.dumps(5, 1)), 5)213 self.assertEqual(marshal.loads(marshal.dumps(5, 0)), 5) 214 self.assertEqual(marshal.loads(marshal.dumps(5, 1)), 5) 213 215 214 216 def test_fuzz(self): … … 251 253 # <type 'int'> 252 254 for typ in (int, long, float, complex, tuple, list, dict, set, frozenset): 253 # Note: str and unicode sub lclasses are not tested because they get handled255 # Note: str and unicode subclasses are not tested because they get handled 254 256 # by marshal's routines for objects supporting the buffer API. 255 257 subtyp = type('subtyp', (typ,), {}) … … 267 269 invalid_string = 'l\x02\x00\x00\x00\x00\x00\x00\x00' 268 270 self.assertRaises(ValueError, marshal.loads, invalid_string) 271 272 LARGE_SIZE = 2**31 273 character_size = 4 if sys.maxunicode > 0xFFFF else 2 274 pointer_size = 8 if sys.maxsize > 0xFFFFFFFF else 4 275 276 @unittest.skipIf(LARGE_SIZE > sys.maxsize, "test cannot run on 32-bit systems") 277 class LargeValuesTestCase(unittest.TestCase): 278 def check_unmarshallable(self, data): 279 f = open(test_support.TESTFN, 'wb') 280 self.addCleanup(test_support.unlink, test_support.TESTFN) 281 with f: 282 self.assertRaises(ValueError, marshal.dump, data, f) 283 284 @test_support.precisionbigmemtest(size=LARGE_SIZE, memuse=1, dry_run=False) 285 def test_string(self, size): 286 self.check_unmarshallable('x' * size) 287 288 @test_support.precisionbigmemtest(size=LARGE_SIZE, 289 memuse=character_size, dry_run=False) 290 def test_unicode(self, size): 291 self.check_unmarshallable(u'x' * size) 292 293 @test_support.precisionbigmemtest(size=LARGE_SIZE, 294 memuse=pointer_size, dry_run=False) 295 def test_tuple(self, size): 296 self.check_unmarshallable((None,) * size) 297 298 @test_support.precisionbigmemtest(size=LARGE_SIZE, 299 memuse=pointer_size, dry_run=False) 300 def test_list(self, size): 301 self.check_unmarshallable([None] * size) 302 303 @test_support.precisionbigmemtest(size=LARGE_SIZE, 304 memuse=pointer_size*12 + sys.getsizeof(LARGE_SIZE-1), 305 dry_run=False) 306 def test_set(self, size): 307 self.check_unmarshallable(set(range(size))) 308 309 @test_support.precisionbigmemtest(size=LARGE_SIZE, 310 memuse=pointer_size*12 + sys.getsizeof(LARGE_SIZE-1), 311 dry_run=False) 312 def test_frozenset(self, size): 313 self.check_unmarshallable(frozenset(range(size))) 314 315 @test_support.precisionbigmemtest(size=LARGE_SIZE, memuse=1, dry_run=False) 316 def test_bytearray(self, size): 317 self.check_unmarshallable(bytearray(size)) 269 318 270 319 … … 276 325 ContainerTestCase, 277 326 ExceptionTestCase, 278 BugsTestCase) 327 BugsTestCase, 328 LargeValuesTestCase, 329 ) 279 330 280 331 if __name__ == "__main__":
Note:
See TracChangeset
for help on using the changeset viewer.