Changeset 391 for python/trunk/Lib/test/test_pyclbr.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_pyclbr.py
r2 r391 3 3 Nick Mathewson 4 4 ''' 5 from test.test_support import run_unittest 5 from test.test_support import run_unittest, import_module 6 6 import sys 7 7 from types import ClassType, FunctionType, MethodType, BuiltinFunctionType … … 12 12 ClassMethodType = type(classmethod(lambda c: None)) 13 13 14 # Silence Py3k warning 15 import_module('commands', deprecated=True) 16 14 17 # This next line triggers an error on old versions of pyclbr. 15 16 18 from commands import getstatus 17 19 … … 36 38 if attr in ignore: return 37 39 if not hasattr(obj, attr): print "???", attr 38 self. failUnless(hasattr(obj, attr),40 self.assertTrue(hasattr(obj, attr), 39 41 'expected hasattr(%r, %r)' % (obj, attr)) 40 42 41 43 42 44 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. ''' 44 46 if key in ignore: return 45 if not obj.has_key(key):46 print >>sys.stderr, "***", key47 self. failUnless(obj.has_key(key))47 if key not in obj: 48 print >>sys.stderr, "***", key 49 self.assertIn(key, obj) 48 50 49 51 def assertEqualsOrIgnored(self, a, b, ignore): 50 52 ''' succeed iff a == b or a in ignore or b in ignore ''' 51 53 if a not in ignore and b not in ignore: 52 self.assertEqual s(a, b)54 self.assertEqual(a, b) 53 55 54 56 def checkModule(self, moduleName, module=None, ignore=()): … … 93 95 py_item = getattr(module, name) 94 96 if isinstance(value, pyclbr.Function): 95 self.assert _(isinstance(py_item, (FunctionType, BuiltinFunctionType)))97 self.assertIsInstance(py_item, (FunctionType, BuiltinFunctionType)) 96 98 if py_item.__module__ != moduleName: 97 99 continue # skip functions that came from somewhere else 98 self.assertEqual s(py_item.__module__, value.module)100 self.assertEqual(py_item.__module__, value.module) 99 101 else: 100 self. failUnless(isinstance(py_item, (ClassType, type)))102 self.assertIsInstance(py_item, (ClassType, type)) 101 103 if py_item.__module__ != moduleName: 102 104 continue # skip classes that came from somewhere else … … 125 127 try: 126 128 self.assertListEq(foundMethods, actualMethods, ignore) 127 self.assertEqual s(py_item.__module__, value.module)129 self.assertEqual(py_item.__module__, value.module) 128 130 129 131 self.assertEqualsOrIgnored(py_item.__name__, value.name, … … 149 151 def test_easy(self): 150 152 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) 153 157 self.checkModule('difflib') 154 158 … … 185 189 cm('test.test_pyclbr') 186 190 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 187 196 188 197 def test_main():
Note:
See TracChangeset
for help on using the changeset viewer.