[Python-checkins] python/dist/src/Lib/test test_array.py,1.14,1.15

mwh@sourceforge.net mwh@sourceforge.net
Wed, 15 May 2002 06:04:56 -0700


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

Modified Files:
	test_array.py 
Log Message:
This is patch

[ 555382 ] test_array v.s. --disable-unicode

+ MvL's suggestions.  Just the 32 failing tests in --disable-unicode builds
now...




Index: test_array.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_array.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** test_array.py	1 Mar 2002 10:27:01 -0000	1.14
--- test_array.py	15 May 2002 13:04:53 -0000	1.15
***************
*** 4,15 ****
  """
  import array
! from test_support import verbose, TESTFN, unlink, TestFailed
  
  def main():
      testtype('c', 'c')
!     testtype('u', u'\u263a')
      for type in (['b', 'h', 'i', 'l', 'f', 'd']):
          testtype(type, 1)
!     testunicode()
      testsubclassing()
      unlink(TESTFN)
--- 4,17 ----
  """
  import array
! from test_support import verbose, TESTFN, unlink, TestFailed, have_unicode
  
  def main():
      testtype('c', 'c')
!     if have_unicode:
!         testtype('u', unicode(r'\u263a', 'unicode-escape'))
      for type in (['b', 'h', 'i', 'l', 'f', 'd']):
          testtype(type, 1)
!     if have_unicode:
!         testunicode()
      testsubclassing()
      unlink(TESTFN)
***************
*** 17,21 ****
  def testunicode():
      try:
!         array.array('b', u'foo')
      except TypeError:
          pass
--- 19,23 ----
  def testunicode():
      try:
!         array.array('b', unicode('foo', 'ascii'))
      except TypeError:
          pass
***************
*** 24,37 ****
                           "a Unicode string should fail")
  
!     x = array.array('u', u'\xa0\xc2\u1234')
!     x.fromunicode(u' ')
!     x.fromunicode(u'')
!     x.fromunicode(u'')
!     x.fromunicode(u'\x11abc\xff\u1234')
      s = x.tounicode()
!     if s != u'\xa0\xc2\u1234 \x11abc\xff\u1234':
          raise TestFailed("fromunicode()/tounicode()")
  
!     s = u'\x00="\'a\\b\x80\xff\u0000\u0001\u1234'
      a = array.array('u', s)
      if verbose:
--- 26,39 ----
                           "a Unicode string should fail")
  
!     x = array.array('u', unicode(r'\xa0\xc2\u1234', 'unicode-escape'))
!     x.fromunicode(unicode(' ', 'ascii'))
!     x.fromunicode(unicode('', 'ascii'))
!     x.fromunicode(unicode('', 'ascii'))
!     x.fromunicode(unicode(r'\x11abc\xff\u1234', 'unicode-escape'))
      s = x.tounicode()
!     if s != unicode(r'\xa0\xc2\u1234 \x11abc\xff\u1234', 'unicode-escape'):
          raise TestFailed("fromunicode()/tounicode()")
  
!     s = unicode(r'\x00="\'a\\b\x80\xff\u0000\u0001\u1234', 'unicode-escape')
      a = array.array('u', s)
      if verbose:
***************
*** 236,264 ****
              raise TestFailed, "array(%s) reverse-test" % `type`
      elif type == 'u':
!         a = array.array(type, u"abcde")
          a[:-1] = a
!         if a != array.array(type, u"abcdee"):
              raise TestFailed, "array(%s) self-slice-assign (head)" % `type`
!         a = array.array(type, u"abcde")
          a[1:] = a
!         if a != array.array(type, u"aabcde"):
              raise TestFailed, "array(%s) self-slice-assign (tail)" % `type`
!         a = array.array(type, u"abcde")
          a[1:-1] = a
!         if a != array.array(type, u"aabcdee"):
              raise TestFailed, "array(%s) self-slice-assign (cntr)" % `type`
!         if a.index(u"e") != 5:
              raise TestFailed, "array(%s) index-test" % `type`
!         if a.count(u"a") != 2:
              raise TestFailed, "array(%s) count-test" % `type`
!         a.remove(u"e")
!         if a != array.array(type, u"aabcde"):
              raise TestFailed, "array(%s) remove-test" % `type`
!         if a.pop(0) != u"a":
              raise TestFailed, "array(%s) pop-test" % `type`
!         if a.pop(1) != u"b":
              raise TestFailed, "array(%s) pop-test" % `type`
!         a.extend(array.array(type, u"xyz"))
!         if a != array.array(type, u"acdexyz"):
              raise TestFailed, "array(%s) extend-test" % `type`
          a.pop()
--- 238,266 ----
              raise TestFailed, "array(%s) reverse-test" % `type`
      elif type == 'u':
!         a = array.array(type, unicode("abcde", 'ascii'))
          a[:-1] = a
!         if a != array.array(type, unicode("abcdee", 'ascii')):
              raise TestFailed, "array(%s) self-slice-assign (head)" % `type`
!         a = array.array(type, unicode("abcde", 'ascii'))
          a[1:] = a
!         if a != array.array(type, unicode("aabcde", 'ascii')):
              raise TestFailed, "array(%s) self-slice-assign (tail)" % `type`
!         a = array.array(type, unicode("abcde", 'ascii'))
          a[1:-1] = a
!         if a != array.array(type, unicode("aabcdee", 'ascii')):
              raise TestFailed, "array(%s) self-slice-assign (cntr)" % `type`
!         if a.index(unicode("e", 'ascii')) != 5:
              raise TestFailed, "array(%s) index-test" % `type`
!         if a.count(unicode("a", 'ascii')) != 2:
              raise TestFailed, "array(%s) count-test" % `type`
!         a.remove(unicode("e", 'ascii'))
!         if a != array.array(type, unicode("aabcde", 'ascii')):
              raise TestFailed, "array(%s) remove-test" % `type`
!         if a.pop(0) != unicode("a", 'ascii'):
              raise TestFailed, "array(%s) pop-test" % `type`
!         if a.pop(1) != unicode("b", 'ascii'):
              raise TestFailed, "array(%s) pop-test" % `type`
!         a.extend(array.array(type, unicode("xyz", 'ascii')))
!         if a != array.array(type, unicode("acdexyz", 'ascii')):
              raise TestFailed, "array(%s) extend-test" % `type`
          a.pop()
***************
*** 266,275 ****
          a.pop()
          x = a.pop()
!         if x != u'e':
              raise TestFailed, "array(%s) pop-test" % `type`
!         if a != array.array(type, u"acd"):
              raise TestFailed, "array(%s) pop-test" % `type`
          a.reverse()
!         if a != array.array(type, u"dca"):
              raise TestFailed, "array(%s) reverse-test" % `type`
      else:
--- 268,277 ----
          a.pop()
          x = a.pop()
!         if x != unicode('e', 'ascii'):
              raise TestFailed, "array(%s) pop-test" % `type`
!         if a != array.array(type, unicode("acd", 'ascii')):
              raise TestFailed, "array(%s) pop-test" % `type`
          a.reverse()
!         if a != array.array(type, unicode("dca", 'ascii')):
              raise TestFailed, "array(%s) reverse-test" % `type`
      else: