Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Lib/test/test_class.py

    r2 r391  
    351351
    352352
     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
    353366    def testUnaryOps(self):
    354367        testme = AllTests()
     
    408421
    409422        callLst[:] = []
    410         testme <> 1  # XXX kill this in py3k
     423        eval('testme <> 1')  # XXX kill this in py3k
    411424        self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (testme, 1))])
    412425
     
    428441
    429442        callLst[:] = []
    430         1 <> testme
     443        eval('1 <> testme')
    431444        self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (1, testme))])
    432445
     
    476489        import gc
    477490        gc.collect()
    478         self.assertEquals(["crab people, crab people"], x)
     491        self.assertEqual(["crab people, crab people"], x)
    479492
    480493    def testBadTypeReturned(self):
     
    508521        callLst[:] = []
    509522        as_int = int(mixIntAndLong)
    510         self.assertEquals(type(as_int), long)
    511         self.assertEquals(as_int, 42L)
     523        self.assertEqual(type(as_int), long)
     524        self.assertEqual(as_int, 42L)
    512525        self.assertCallStack([('__int__', (mixIntAndLong,))])
    513526
    514527        callLst[:] = []
    515528        as_long = long(mixIntAndLong)
    516         self.assertEquals(type(as_long), int)
    517         self.assertEquals(as_long, 64)
     529        self.assertEqual(type(as_long), long)
     530        self.assertEqual(as_long, 64)
    518531        self.assertCallStack([('__long__', (mixIntAndLong,))])
    519532
     
    600613        a1 = A(1)
    601614        a2 = A(2)
    602         self.assertEquals(a1.f, a1.f)
    603         self.assertNotEquals(a1.f, a2.f)
    604         self.assertNotEquals(a1.f, a1.g)
    605         self.assertEquals(a1.f, A(1).f)
    606         self.assertEquals(hash(a1.f), hash(a1.f))
    607         self.assertEquals(hash(a1.f), hash(A(1).f))
    608 
    609         self.assertNotEquals(A.f, a1.f)
    610         self.assertNotEquals(A.f, A.g)
    611         self.assertEquals(B.f, A.f)
    612         self.assertEquals(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))
    613626
    614627        # the following triggers a SystemError in 2.4
     
    616629        hash(a.f)
    617630
     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
    618638def 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)
    620644
    621645if __name__=='__main__':
Note: See TracChangeset for help on using the changeset viewer.