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

Tim Peters tim_one@users.sourceforge.net
Tue, 11 Sep 2001 22:19:00 -0700


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

Modified Files:
	test_descr.py 
Log Message:
str_subtype_new, unicode_subtype_new:
+ These were leaving the hash fields at 0, which all string and unicode
  routines believe is a legitimate hash code.  As a result, hash() applied
  to str and unicode subclass instances always returned 0, which in turn
  confused dict operations, etc.
+ Changed local names "new"; no point to antagonizing C++ compilers.


Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -d -r1.46 -r1.47
*** test_descr.py	2001/09/12 03:03:30	1.46
--- test_descr.py	2001/09/12 05:18:58	1.47
***************
*** 1367,1370 ****
--- 1367,1371 ----
      verify(int(a) == 12345)
      verify(int(a).__class__ is int)
+     verify(hash(a) == hash(12345))
      verify((+a).__class__ is int)
      verify((a >> 0).__class__ is int)
***************
*** 1389,1392 ****
--- 1390,1394 ----
      a = octlong(12345)
      verify(long(a) == 12345L)
+     verify(hash(a) == hash(12345L))
      verify(long(a).__class__ is long)
      verify((+a).__class__ is long)
***************
*** 1426,1429 ****
--- 1428,1432 ----
      verify(float(a) == 12345.0)
      verify(float(a).__class__ is float)
+     verify(hash(a) == hash(12345.0))
      verify((+a).__class__ is float)
  
***************
*** 1448,1451 ****
--- 1451,1455 ----
      verify(tuple(a) == (1,2,3,4,5))
      verify(tuple(a).__class__ is tuple)
+     verify(hash(a) == hash((1,2,3,4,5)))
      verify(a[:].__class__ is tuple)
      verify((a * 1).__class__ is tuple)
***************
*** 1486,1489 ****
--- 1490,1496 ----
      verify(str(s) == base)
      verify(str(s).__class__ is str)
+     verify(hash(s) == hash(base))
+     verify({s: 1}[base] == 1)
+     verify({base: 1}[s] == 1)
      verify((s + "").__class__ is str)
      verify(s + "" == base)
***************
*** 1539,1542 ****
--- 1546,1552 ----
      verify(unicode(u) == base)
      verify(unicode(u).__class__ is unicode)
+     verify(hash(u) == hash(base))
+     verify({u: 1}[base] == 1)
+     verify({base: 1}[u] == 1)
      verify(u.strip().__class__ is unicode)
      verify(u.strip() == base)