[Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.1.2.11,1.1.2.12

Guido van Rossum gvanrossum@users.sourceforge.net
Thu, 07 Jun 2001 08:45:06 -0700


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

Modified Files:
      Tag: descr-branch
	test_descr.py 
Log Message:
Change type({}) to dictionary.
Rename the baseless() test to metaclass(), and test only that.
Add a new test for multiple inheritance.


Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/Attic/test_descr.py,v
retrieving revision 1.1.2.11
retrieving revision 1.1.2.12
diff -C2 -r1.1.2.11 -r1.1.2.12
*** test_descr.py	2001/06/06 01:03:14	1.1.2.11
--- test_descr.py	2001/06/07 15:45:04	1.1.2.12
***************
*** 117,121 ****
      verify(l == l1)
      l = []
!     for i in type({}).__iter__(d): l.append(i)
      verify(l == l1)
      testunop({1:2,3:4}, 2, "len(a)", "__len__")
--- 117,121 ----
      verify(l == l1)
      l = []
!     for i in dictionary.__iter__(d): l.append(i)
      verify(l == l1)
      testunop({1:2,3:4}, 2, "len(a)", "__len__")
***************
*** 256,270 ****
                 "a[b]=c", "__setitem__")
  
- DT = type({})
- 
  def pydicts():
      if verbose: print "Testing Python subclass of dict..."
!     verify(issubclass(DT, DT))
!     verify(isinstance({}, DT))
!     d = DT()
      verify(d == {})
!     verify(d.__class__ is DT)
!     verify(isinstance(d, DT))
!     class C(DT):
          state = -1
          def __init__(self, *a, **kw):
--- 256,268 ----
                 "a[b]=c", "__setitem__")
  
  def pydicts():
      if verbose: print "Testing Python subclass of dict..."
!     verify(issubclass(dictionary, dictionary))
!     verify(isinstance({}, dictionary))
!     d = dictionary()
      verify(d == {})
!     verify(d.__class__ is dictionary)
!     verify(isinstance(d, dictionary))
!     class C(dictionary):
          state = -1
          def __init__(self, *a, **kw):
***************
*** 278,287 ****
          def __setitem__(self, key, value):
              assert isinstance(key, type(0))
!             DT.__setitem__(self, key, value)
          def setstate(self, state):
              self.state = state
          def getstate(self):
              return self.state
!     verify(issubclass(C, DT))
      a1 = C(12)
      verify(a1.state == 12)
--- 276,285 ----
          def __setitem__(self, key, value):
              assert isinstance(key, type(0))
!             dictionary.__setitem__(self, key, value)
          def setstate(self, state):
              self.state = state
          def getstate(self):
              return self.state
!     verify(issubclass(C, dictionary))
      a1 = C(12)
      verify(a1.state == 12)
***************
*** 309,312 ****
--- 307,326 ----
              verify(a[i][j] == i*j)
  
+ def metaclass():
+     if verbose: print "Testing __metaclass__..."
+     global C
+     class C:
+         __metaclass__ = type(type(0))
+         def __init__(self):
+             self.__state = 0
+         def getstate(self):
+             return self.__state
+         def setstate(self, state):
+             self.__state = state
+     a = C()
+     verify(a.getstate() == 0)
+     a.setstate(10)
+     verify(a.getstate() == 10)
+ 
  import sys
  MT = type(sys)
***************
*** 339,347 ****
                     ("delattr", "foo")], log)
  
! def baseless():
!     if verbose: print "Testing __metaclass__ and mix-ins..."
      global C
!     class C:
!         __metaclass__ = type(type(0))
          def __init__(self):
              self.__state = 0
--- 353,360 ----
                     ("delattr", "foo")], log)
  
! def multi():
!     if verbose: print "Testing multiple inheritance..."
      global C
!     class C(object):
          def __init__(self):
              self.__state = 0
***************
*** 354,358 ****
      a.setstate(10)
      verify(a.getstate() == 10)
!     class D(type({}), C):
          def __init__(self):
              type({}).__init__(self)
--- 367,371 ----
      a.setstate(10)
      verify(a.getstate() == 10)
!     class D(dictionary, C):
          def __init__(self):
              type({}).__init__(self)
***************
*** 376,381 ****
      spamdicts()
      pydicts()
      pymods()
!     baseless()
  
  all()
--- 389,395 ----
      spamdicts()
      pydicts()
+     metaclass()
      pymods()
!     multi()
  
  all()