Changeset 391 for python/trunk/Lib/test/test_class.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_class.py
r2 r391 351 351 352 352 353 @test_support.cpython_only 354 def testDelItem(self): 355 class A: 356 ok = False 357 def __delitem__(self, key): 358 self.ok = True 359 a = A() 360 # Subtle: we need to call PySequence_SetItem, not PyMapping_SetItem. 361 from _testcapi import sequence_delitem 362 sequence_delitem(a, 2) 363 self.assertTrue(a.ok) 364 365 353 366 def testUnaryOps(self): 354 367 testme = AllTests() … … 408 421 409 422 callLst[:] = [] 410 testme <> 1# XXX kill this in py3k423 eval('testme <> 1') # XXX kill this in py3k 411 424 self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (testme, 1))]) 412 425 … … 428 441 429 442 callLst[:] = [] 430 1 <> testme443 eval('1 <> testme') 431 444 self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (1, testme))]) 432 445 … … 476 489 import gc 477 490 gc.collect() 478 self.assertEqual s(["crab people, crab people"], x)491 self.assertEqual(["crab people, crab people"], x) 479 492 480 493 def testBadTypeReturned(self): … … 508 521 callLst[:] = [] 509 522 as_int = int(mixIntAndLong) 510 self.assertEqual s(type(as_int), long)511 self.assertEqual s(as_int, 42L)523 self.assertEqual(type(as_int), long) 524 self.assertEqual(as_int, 42L) 512 525 self.assertCallStack([('__int__', (mixIntAndLong,))]) 513 526 514 527 callLst[:] = [] 515 528 as_long = long(mixIntAndLong) 516 self.assertEqual s(type(as_long), int)517 self.assertEqual s(as_long, 64)529 self.assertEqual(type(as_long), long) 530 self.assertEqual(as_long, 64) 518 531 self.assertCallStack([('__long__', (mixIntAndLong,))]) 519 532 … … 600 613 a1 = A(1) 601 614 a2 = A(2) 602 self.assertEqual s(a1.f, a1.f)603 self.assertNotEqual s(a1.f, a2.f)604 self.assertNotEqual s(a1.f, a1.g)605 self.assertEqual s(a1.f, A(1).f)606 self.assertEqual s(hash(a1.f), hash(a1.f))607 self.assertEqual s(hash(a1.f), hash(A(1).f))608 609 self.assertNotEqual s(A.f, a1.f)610 self.assertNotEqual s(A.f, A.g)611 self.assertEqual s(B.f, A.f)612 self.assertEqual s(hash(B.f), hash(A.f))615 self.assertEqual(a1.f, a1.f) 616 self.assertNotEqual(a1.f, a2.f) 617 self.assertNotEqual(a1.f, a1.g) 618 self.assertEqual(a1.f, A(1).f) 619 self.assertEqual(hash(a1.f), hash(a1.f)) 620 self.assertEqual(hash(a1.f), hash(A(1).f)) 621 622 self.assertNotEqual(A.f, a1.f) 623 self.assertNotEqual(A.f, A.g) 624 self.assertEqual(B.f, A.f) 625 self.assertEqual(hash(B.f), hash(A.f)) 613 626 614 627 # the following triggers a SystemError in 2.4 … … 616 629 hash(a.f) 617 630 631 def testAttrSlots(self): 632 class C: 633 pass 634 for c in C, C(): 635 self.assertRaises(TypeError, type(c).__getattribute__, c, []) 636 self.assertRaises(TypeError, type(c).__setattr__, c, [], []) 637 618 638 def test_main(): 619 test_support.run_unittest(ClassTests) 639 with test_support.check_py3k_warnings( 640 (".+__(get|set|del)slice__ has been removed", DeprecationWarning), 641 ("classic int division", DeprecationWarning), 642 ("<> not supported", DeprecationWarning)): 643 test_support.run_unittest(ClassTests) 620 644 621 645 if __name__=='__main__':
Note:
See TracChangeset
for help on using the changeset viewer.