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

    r2 r391  
    33   Nick Mathewson
    44'''
    5 from test.test_support import run_unittest
     5from test.test_support import run_unittest, import_module
    66import sys
    77from types import ClassType, FunctionType, MethodType, BuiltinFunctionType
     
    1212ClassMethodType = type(classmethod(lambda c: None))
    1313
     14# Silence Py3k warning
     15import_module('commands', deprecated=True)
     16
    1417# This next line triggers an error on old versions of pyclbr.
    15 
    1618from commands import getstatus
    1719
     
    3638        if attr in ignore: return
    3739        if not hasattr(obj, attr): print "???", attr
    38         self.failUnless(hasattr(obj, attr),
     40        self.assertTrue(hasattr(obj, attr),
    3941                        'expected hasattr(%r, %r)' % (obj, attr))
    4042
    4143
    4244    def assertHaskey(self, obj, key, ignore):
    43         ''' succeed iff obj.has_key(key) or key in ignore. '''
     45        ''' succeed iff key in obj or key in ignore. '''
    4446        if key in ignore: return
    45         if not obj.has_key(key):
    46             print >>sys.stderr, "***",key
    47         self.failUnless(obj.has_key(key))
     47        if key not in obj:
     48            print >>sys.stderr, "***", key
     49        self.assertIn(key, obj)
    4850
    4951    def assertEqualsOrIgnored(self, a, b, ignore):
    5052        ''' succeed iff a == b or a in ignore or b in ignore '''
    5153        if a not in ignore and b not in ignore:
    52             self.assertEquals(a, b)
     54            self.assertEqual(a, b)
    5355
    5456    def checkModule(self, moduleName, module=None, ignore=()):
     
    9395            py_item = getattr(module, name)
    9496            if isinstance(value, pyclbr.Function):
    95                 self.assert_(isinstance(py_item, (FunctionType, BuiltinFunctionType)))
     97                self.assertIsInstance(py_item, (FunctionType, BuiltinFunctionType))
    9698                if py_item.__module__ != moduleName:
    9799                    continue   # skip functions that came from somewhere else
    98                 self.assertEquals(py_item.__module__, value.module)
     100                self.assertEqual(py_item.__module__, value.module)
    99101            else:
    100                 self.failUnless(isinstance(py_item, (ClassType, type)))
     102                self.assertIsInstance(py_item, (ClassType, type))
    101103                if py_item.__module__ != moduleName:
    102104                    continue   # skip classes that came from somewhere else
     
    125127                try:
    126128                    self.assertListEq(foundMethods, actualMethods, ignore)
    127                     self.assertEquals(py_item.__module__, value.module)
     129                    self.assertEqual(py_item.__module__, value.module)
    128130
    129131                    self.assertEqualsOrIgnored(py_item.__name__, value.name,
     
    149151    def test_easy(self):
    150152        self.checkModule('pyclbr')
    151         self.checkModule('doctest')
    152         self.checkModule('rfc822')
     153        self.checkModule('doctest', ignore=("DocTestCase",))
     154        # Silence Py3k warning
     155        rfc822 = import_module('rfc822', deprecated=True)
     156        self.checkModule('rfc822', rfc822)
    153157        self.checkModule('difflib')
    154158
     
    185189        cm('test.test_pyclbr')
    186190
     191    def test_issue_14798(self):
     192        # test ImportError is raised when the first part of a dotted name is
     193        # not a package
     194        self.assertRaises(ImportError, pyclbr.readmodule_ex, 'asyncore.foo')
     195
    187196
    188197def test_main():
Note: See TracChangeset for help on using the changeset viewer.