[Python-checkins] python/dist/src/Lib/test test_pyclbr.py,1.13,1.14

gvanrossum@users.sourceforge.net gvanrossum@users.sourceforge.net
Tue, 03 Dec 2002 00:16:53 -0800


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv6788

Modified Files:
	test_pyclbr.py 
Log Message:
Add more sophistication to the comparison between pyclbr output and
real module, by filtering out aliased methods.  This, combined with
the recent fixes to pyclbr, make it possible to enable more tests with
fewer exceptions.


Index: test_pyclbr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pyclbr.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** test_pyclbr.py	2 Dec 2002 14:54:20 -0000	1.13
--- test_pyclbr.py	3 Dec 2002 08:16:50 -0000	1.14
***************
*** 24,27 ****
--- 24,29 ----
      def assertListEq(self, l1, l2, ignore):
          ''' succeed iff {l1} - {ignore} == {l2} - {ignore} '''
+         l1.sort()
+         l2.sort()
          try:
              for p1, p2 in (l1, l2), (l2, l1):
***************
*** 31,35 ****
                          self.fail("%r missing" % item)
          except:
!             print >>sys.stderr, "l1=%r, l2=%r, ignore=%r" % (l1, l2, ignore)
              raise
  
--- 33,37 ----
                          self.fail("%r missing" % item)
          except:
!             print >>sys.stderr, "l1=%r\nl2=%r\nignore=%r" % (l1, l2, ignore)
              raise
  
***************
*** 68,71 ****
--- 70,83 ----
          dict = pyclbr.readmodule_ex(moduleName)
  
+         def ismethod(obj, name):
+             if not  isinstance(obj, MethodType):
+                 return False
+             if obj.im_self is not None:
+                 return False
+             objname = obj.__name__
+             if objname.startswith("__") and not objname.endswith("__"):
+                 objname = "_%s%s" % (obj.im_class.__name__, objname)
+             return objname == name
+ 
          # Make sure the toplevel functions and classes are the same.
          for name, value in dict.items():
***************
*** 90,94 ****
                  actualMethods = []
                  for m in py_item.__dict__.keys():
!                     if type(getattr(py_item, m)) == MethodType:
                          actualMethods.append(m)
                  foundMethods = []
--- 102,106 ----
                  actualMethods = []
                  for m in py_item.__dict__.keys():
!                     if ismethod(getattr(py_item, m), m):
                          actualMethods.append(m)
                  foundMethods = []
***************
*** 99,107 ****
                          foundMethods.append(m)
  
!                 self.assertListEq(foundMethods, actualMethods, ignore)
!                 self.assertEquals(py_item.__module__, value.module)
  
!                 self.assertEquals(py_item.__name__, value.name, ignore)
!                 # can't check file or lineno
  
          # Now check for missing stuff.
--- 111,123 ----
                          foundMethods.append(m)
  
!                 try:
!                     self.assertListEq(foundMethods, actualMethods, ignore)
!                     self.assertEquals(py_item.__module__, value.module)
  
!                     self.assertEquals(py_item.__name__, value.name, ignore)
!                     # can't check file or lineno
!                 except:
!                     print >>sys.stderr, "class=%s" % py_item
!                     raise
  
          # Now check for missing stuff.
***************
*** 120,129 ****
      def test_easy(self):
          self.checkModule('pyclbr')
!         self.checkModule('doctest',
!                          ignore=['_isclass',
!                                  '_isfunction',
!                                  '_ismodule',
!                                  '_classify_class_attrs'])
!         self.checkModule('rfc822', ignore=["get"])
          self.checkModule('difflib')
  
--- 136,141 ----
      def test_easy(self):
          self.checkModule('pyclbr')
!         self.checkModule('doctest')
!         self.checkModule('rfc822')
          self.checkModule('difflib')
  
***************
*** 131,168 ****
          cm = self.checkModule
  
!         # these are about the 20 longest modules.
! 
          cm('random', ignore=('_verify',)) # deleted
! 
!         cm('cgi', ignore=('f', 'g',       # nested declarations
!                           'log'))         # set with =, not def
! 
!         cm('mhlib', ignore=('do',          # nested declaration
!                             'bisect'))     # imported method, set with =
! 
!         cm('urllib', ignore=('getproxies_environment', # set with =
!                              'getproxies_registry',    # set with =
!                              'open_https'))            # not on all platforms
! 
!         cm('pickle', ignore=('g',))       # deleted declaration
! 
!         cm('aifc', ignore=('openfp',))    # set with =
! 
!         cm('Cookie', ignore=('__str__', 'Cookie')) # set with =
! 
!         cm('sre_parse', ignore=('literal', # nested def
!                                 'makedict', 'dump' # from sre_constants
!                                 ))
  
          # Tests for modules inside packages
          cm('email.Parser')
! 
!         cm('test.test_pyclbr', ignore=('defined_in',))
! 
!         # pydoc doesn't work because of string issues
!         # cm('pydoc', pydoc)
! 
!         # pdb plays too many dynamic games
!         # cm('pdb', pdb)
  
  
--- 143,162 ----
          cm = self.checkModule
  
!         # These were once about the 10 longest modules
          cm('random', ignore=('_verify',)) # deleted
!         cm('cgi', ignore=('log',))      # set with = in module
!         cm('mhlib')
!         cm('urllib', ignore=('getproxies_registry',
!                              'open_https')) # not on all platforms
!         cm('pickle', ignore=('g',))     # from types import *
!         cm('aifc', ignore=('openfp',))  # set with = in module
!         cm('Cookie')
!         cm('sre_parse', ignore=('dump',)) # from sre_constants import *
!         cm('pdb')
!         cm('pydoc')
  
          # Tests for modules inside packages
          cm('email.Parser')
!         cm('test.test_pyclbr')