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

Tim Peters tim_one@users.sourceforge.net
Mon, 10 Sep 2001 13:52:53 -0700


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

Modified Files:
	test_descr.py 
Log Message:
SF bug #460020:  bug or feature: unicode() and subclasses.
Given an immutable type M, and an instance I of a subclass of M, the
constructor call M(I) was just returning I as-is; but it should return a
new instance of M.  This fixes it for M in {int, long}.  Strings, floats
and tuples remain to be done.
Added new macros PyInt_CheckExact and PyLong_CheckExact, to more easily
distinguish between "is" and "is a" (i.e., only an int passes
PyInt_CheckExact, while any sublass of int passes PyInt_Check).
Added private API function _PyLong_Copy.


Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** test_descr.py	2001/09/06 21:56:42	1.32
--- test_descr.py	2001/09/10 20:52:47	1.33
***************
*** 1341,1344 ****
--- 1341,1347 ----
      verify(repr(hexint(7) + 9) == "0x10")
      verify(repr(hexint(1000) + 7) == "0x3ef")
+     a = hexint(12345)
+     #XXX verify(int(a) == 12345)
+     verify(int(a).__class__ is int)
  
      class octlong(long):
***************
*** 1356,1359 ****
--- 1359,1365 ----
      # because the example uses a short int left argument.)
      verify(str(5 + octlong(3000)) == "05675")
+     a = octlong(12345)
+     #XXX verify(long(a) == 12345L)
+     verify(long(a).__class__ is long)
  
      class precfloat(float):
***************
*** 1365,1368 ****
--- 1371,1377 ----
              return "%.*g" % (self.prec, self)
      verify(repr(precfloat(1.1)) == "1.1")
+     a = precfloat(12345)
+     #XXX verify(float(a) == 12345.0)
+     #XXX verify(float(a).__class__ is float)
  
      class madtuple(tuple):
***************
*** 1383,1386 ****
--- 1392,1401 ----
          v = u.rev()
          verify(v == t)
+     a = madtuple((1,2,3,4,5))
+     verify(tuple(a) == (1,2,3,4,5))
+     #XXX verify(tuple(a).__class__ is tuple)
+     a = madtuple(())
+     verify(tuple(a) == ())
+     #XXX verify(tuple(a).__class__ is tuple)
  
      class madstring(str):
***************
*** 1401,1404 ****
--- 1416,1422 ----
          u = t.rev()
          verify(u == s)
+     s = madstring("12345")
+     #XXX verify(str(s) == "12345")
+     #XXX verify(str(s).__class__ is str)
  
      class madunicode(unicode):
***************
*** 1414,1417 ****
--- 1432,1438 ----
      verify(u.rev() == madunicode(u"FEDCBA"))
      verify(u.rev().rev() == madunicode(u"ABCDEF"))
+     u = madunicode(u"12345")
+     verify(unicode(u) == u"12345")
+     #XXX verify(unicode(u).__class__ is unicode)
  
  def all():