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

    r2 r391  
    99import unittest
    1010
    11 from test.test_support import run_unittest
     11from test.test_support import run_unittest, check_py3k_warnings
    1212from repr import repr as r # Don't shadow builtin repr
    1313from repr import Repr
     
    2323
    2424    def test_string(self):
    25         eq = self.assertEquals
     25        eq = self.assertEqual
    2626        eq(r("abc"), "'abc'")
    2727        eq(r("abcdefghijklmnop"),"'abcdefghijklmnop'")
     
    3737
    3838    def test_tuple(self):
    39         eq = self.assertEquals
     39        eq = self.assertEqual
    4040        eq(r((1,)), "(1,)")
    4141
     
    5252        from collections import deque
    5353
    54         eq = self.assertEquals
     54        eq = self.assertEqual
    5555        # Tuples give up after 6 elements
    5656        eq(r(()), "()")
     
    102102
    103103    def test_numbers(self):
    104         eq = self.assertEquals
     104        eq = self.assertEqual
    105105        eq(r(123), repr(123))
    106106        eq(r(123L), repr(123L))
     
    112112
    113113    def test_instance(self):
    114         eq = self.assertEquals
     114        eq = self.assertEqual
    115115        i1 = ClassWithRepr("a")
    116116        eq(r(i1), repr(i1))
     
    124124
    125125        s = r(ClassWithFailingRepr)
    126         self.failUnless(s.startswith("<class "))
    127         self.failUnless(s.endswith(">"))
    128         self.failUnless(s.find("...") == 8)
     126        self.assertTrue(s.startswith("<class "))
     127        self.assertTrue(s.endswith(">"))
     128        self.assertTrue(s.find("...") == 8)
    129129
    130130    def test_file(self):
    131131        fp = open(unittest.__file__)
    132         self.failUnless(repr(fp).startswith(
    133             "<open file '%s', mode 'r' at 0x" % unittest.__file__))
     132        self.assertTrue(repr(fp).startswith(
     133            "<open file %r, mode 'r' at 0x" % unittest.__file__))
    134134        fp.close()
    135         self.failUnless(repr(fp).startswith(
    136             "<closed file '%s', mode 'r' at 0x" % unittest.__file__))
     135        self.assertTrue(repr(fp).startswith(
     136            "<closed file %r, mode 'r' at 0x" % unittest.__file__))
    137137
    138138    def test_lambda(self):
    139         self.failUnless(repr(lambda x: x).startswith(
     139        self.assertTrue(repr(lambda x: x).startswith(
    140140            "<function <lambda"))
    141141        # XXX anonymous functions?  see func_repr
    142142
    143143    def test_builtin_function(self):
    144         eq = self.assertEquals
     144        eq = self.assertEqual
    145145        # Functions
    146146        eq(repr(hash), '<built-in function hash>')
    147147        # Methods
    148         self.failUnless(repr(''.split).startswith(
     148        self.assertTrue(repr(''.split).startswith(
    149149            '<built-in method split of str object at 0x'))
    150150
    151151    def test_xrange(self):
    152         eq = self.assertEquals
     152        eq = self.assertEqual
    153153        eq(repr(xrange(1)), 'xrange(1)')
    154154        eq(repr(xrange(1, 2)), 'xrange(1, 2)')
     
    156156
    157157    def test_nesting(self):
    158         eq = self.assertEquals
     158        eq = self.assertEqual
    159159        # everything is meant to give up after 6 levels.
    160160        eq(r([[[[[[[]]]]]]]), "[[[[[[[]]]]]]]")
     
    175175        # XXX doesn't test buffers with no b_base or read-write buffers (see
    176176        # bufferobject.c).  The test is fairly incomplete too.  Sigh.
    177         x = buffer('foo')
    178         self.failUnless(repr(x).startswith('<read-only buffer for 0x'))
     177        with check_py3k_warnings():
     178            x = buffer('foo')
     179        self.assertTrue(repr(x).startswith('<read-only buffer for 0x'))
    179180
    180181    def test_cell(self):
     
    183184
    184185    def test_descriptors(self):
    185         eq = self.assertEquals
     186        eq = self.assertEqual
    186187        # method descriptors
    187188        eq(repr(dict.items), "<method 'items' of 'dict' objects>")
     
    193194            def foo(cls): pass
    194195        x = staticmethod(C.foo)
    195         self.failUnless(repr(x).startswith('<staticmethod object at 0x'))
     196        self.assertTrue(repr(x).startswith('<staticmethod object at 0x'))
    196197        x = classmethod(C.foo)
    197         self.failUnless(repr(x).startswith('<classmethod object at 0x'))
     198        self.assertTrue(repr(x).startswith('<classmethod object at 0x'))
    198199
    199200    def test_unsortable(self):
     
    244245
    245246    def test_module(self):
    246         eq = self.assertEquals
     247        eq = self.assertEqual
    247248        touch(os.path.join(self.subpkgname, self.pkgname + os.extsep + 'py'))
    248249        from areallylongpackageandmodulenametotestreprtruncation.areallylongpackageandmodulenametotestreprtruncation import areallylongpackageandmodulenametotestreprtruncation
     
    252253
    253254    def test_type(self):
    254         eq = self.assertEquals
     255        eq = self.assertEqual
    255256        touch(os.path.join(self.subpkgname, 'foo'+os.extsep+'py'), '''\
    256257class foo(object):
     
    273274        from areallylongpackageandmodulenametotestreprtruncation.areallylongpackageandmodulenametotestreprtruncation import bar
    274275        # Module name may be prefixed with "test.", depending on how run.
    275         self.failUnless(repr(bar.bar).startswith(
     276        self.assertTrue(repr(bar.bar).startswith(
    276277            "<class %s.bar at 0x" % bar.__name__))
    277278
     
    283284        from areallylongpackageandmodulenametotestreprtruncation.areallylongpackageandmodulenametotestreprtruncation import baz
    284285        ibaz = baz.baz()
    285         self.failUnless(repr(ibaz).startswith(
     286        self.assertTrue(repr(ibaz).startswith(
    286287            "<%s.baz instance at 0x" % baz.__name__))
    287288
    288289    def test_method(self):
    289         eq = self.assertEquals
     290        eq = self.assertEqual
    290291        touch(os.path.join(self.subpkgname, 'qux'+os.extsep+'py'), '''\
    291292class aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:
     
    298299        # Bound method next
    299300        iqux = qux.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()
    300         self.failUnless(repr(iqux.amethod).startswith(
     301        self.assertTrue(repr(iqux.amethod).startswith(
    301302            '<bound method aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.amethod of <%s.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa instance at 0x' \
    302303            % (qux.__name__,) ))
     
    320321def test_main():
    321322    run_unittest(ReprTests)
    322     if os.name != 'mac':
    323         run_unittest(LongReprTest)
     323    run_unittest(LongReprTest)
    324324
    325325
Note: See TracChangeset for help on using the changeset viewer.