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_coercion.py

    r2 r391  
    11import copy
    2 import warnings
    32import unittest
    4 from test.test_support import run_unittest, TestFailed
     3from test.test_support import run_unittest, TestFailed, check_warnings
     4
    55
    66# Fake a number that implements numeric methods through __coerce__
     
    224224
    225225
    226 
    227 process_infix_results()
    228 # now infix_results has two lists of results for every pairing.
     226with check_warnings(("classic (int|long) division", DeprecationWarning),
     227                    quiet=True):
     228    process_infix_results()
     229    # now infix_results has two lists of results for every pairing.
    229230
    230231prefix_binops = [ 'divmod' ]
     
    266267                                          'a %s b' % op, {'a': a, 'b': b})
    267268                    else:
    268                         self.assertEquals(format_result(res),
    269                                           format_result(eval('a %s b' % op)),
    270                                           '%s %s %s == %s failed' % (a, op, b, res))
     269                        self.assertEqual(format_result(res),
     270                                         format_result(eval('a %s b' % op)),
     271                                         '%s %s %s == %s failed' % (a, op, b, res))
    271272                    try:
    272273                        z = copy.copy(a)
     
    282283                    else:
    283284                        exec('z %s= b' % op)
    284                         self.assertEquals(ires, z)
     285                        self.assertEqual(ires, z)
    285286
    286287    def test_prefix_binops(self):
     
    293294                                          '%s(a, b)' % op, {'a': a, 'b': b})
    294295                    else:
    295                         self.assertEquals(format_result(res),
    296                                           format_result(eval('%s(a, b)' % op)),
    297                                           '%s(%s, %s) == %s failed' % (op, a, b, res))
     296                        self.assertEqual(format_result(res),
     297                                         format_result(eval('%s(a, b)' % op)),
     298                                         '%s(%s, %s) == %s failed' % (op, a, b, res))
    298299
    299300    def test_cmptypes(self):
     
    303304        evil_coercer = CoerceTo(42)
    304305        # Make sure these don't crash any more
    305         self.assertNotEquals(cmp(u'fish', evil_coercer), 0)
    306         self.assertNotEquals(cmp(slice(1), evil_coercer), 0)
     306        self.assertNotEqual(cmp(u'fish', evil_coercer), 0)
     307        self.assertNotEqual(cmp(slice(1), evil_coercer), 0)
    307308        # ...but that this still works
    308309        class WackyComparer(object):
    309310            def __cmp__(slf, other):
    310                 self.assert_(other == 42, 'expected evil_coercer, got %r' % other)
     311                self.assertTrue(other == 42, 'expected evil_coercer, got %r' % other)
    311312                return 0
    312313            __hash__ = None # Invalid cmp makes this unhashable
    313         self.assertEquals(cmp(WackyComparer(), evil_coercer), 0)
     314        self.assertEqual(cmp(WackyComparer(), evil_coercer), 0)
    314315        # ...and classic classes too, since that code path is a little different
    315316        class ClassicWackyComparer:
    316317            def __cmp__(slf, other):
    317                 self.assert_(other == 42, 'expected evil_coercer, got %r' % other)
     318                self.assertTrue(other == 42, 'expected evil_coercer, got %r' % other)
    318319                return 0
    319         self.assertEquals(cmp(ClassicWackyComparer(), evil_coercer), 0)
     320        self.assertEqual(cmp(ClassicWackyComparer(), evil_coercer), 0)
    320321
    321322    def test_infinite_rec_classic_classes(self):
     
    338339
    339340def test_main():
    340     warnings.filterwarnings("ignore",
    341                             r'complex divmod\(\), // and % are deprecated',
    342                             DeprecationWarning,
    343                             r'test.test_coercion$')
    344     run_unittest(CoercionTest)
     341    with check_warnings(("complex divmod.., // and % are deprecated",
     342                         DeprecationWarning),
     343                        ("classic (int|long) division", DeprecationWarning),
     344                        quiet=True):
     345        run_unittest(CoercionTest)
    345346
    346347if __name__ == "__main__":
Note: See TracChangeset for help on using the changeset viewer.