[Python-checkins] CVS: python/dist/src/Lib/test test_unicode.py,1.22,1.23

Guido van Rossum python-dev@python.org
Wed, 29 Nov 2000 04:14:02 -0800


Update of /cvsroot/python/python/dist/src/Lib/test
In directory slayer.i.sourceforge.net:/tmp/cvs-serv16711

Modified Files:
	test_unicode.py 
Log Message:
Slight improvement to Unicode test suite, inspired by patch #102563:
also test join method of 8-bit strings.

Also changed the test() function to (1) compare the types of the
expected and actual result, and (2) in verbose mode, print the repr()
of the output.


Index: test_unicode.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode.py,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -r1.22 -r1.23
*** test_unicode.py	2000/10/23 17:22:08	1.22
--- test_unicode.py	2000/11/29 12:13:59	1.23
***************
*** 11,15 ****
  def test(method, input, output, *args):
      if verbose:
!         print '%s.%s%s =? %s... ' % (repr(input), method, args, output),
      try:
          f = getattr(input, method)
--- 11,15 ----
  def test(method, input, output, *args):
      if verbose:
!         print '%s.%s%s =? %s... ' % (repr(input), method, args, repr(output)),
      try:
          f = getattr(input, method)
***************
*** 20,24 ****
      else:
          exc = None
!     if value != output:
          if verbose:
              print 'no'
--- 20,24 ----
      else:
          exc = None
!     if value != output or type(value) is not type(output):
          if verbose:
              print 'no'
***************
*** 71,87 ****
  # join now works with any sequence type
  class Sequence:
!     def __init__(self): self.seq = 'wxyz'
      def __len__(self): return len(self.seq)
      def __getitem__(self, i): return self.seq[i]
  
  test('join', u' ', u'a b c d', [u'a', u'b', u'c', u'd'])
  test('join', u'', u'abcd', (u'a', u'b', u'c', u'd'))
! test('join', u' ', u'w x y z', Sequence())
  test('join', u' ', TypeError, 7)
! 
! class BadSeq(Sequence):
!     def __init__(self): self.seq = [7, u'hello', 123L]
! 
! test('join', u' ', TypeError, BadSeq())
  
  result = u''
--- 71,89 ----
  # join now works with any sequence type
  class Sequence:
!     def __init__(self, seq): self.seq = seq
      def __len__(self): return len(self.seq)
      def __getitem__(self, i): return self.seq[i]
  
  test('join', u' ', u'a b c d', [u'a', u'b', u'c', u'd'])
+ test('join', u' ', u'a b c d', ['a', 'b', u'c', u'd'])
  test('join', u'', u'abcd', (u'a', u'b', u'c', u'd'))
! test('join', u' ', u'w x y z', Sequence('wxyz'))
  test('join', u' ', TypeError, 7)
! test('join', u' ', TypeError, Sequence([7, u'hello', 123L]))
! test('join', ' ', u'a b c d', [u'a', u'b', u'c', u'd'])
! test('join', ' ', u'a b c d', ['a', 'b', u'c', u'd'])
! test('join', '', u'abcd', (u'a', u'b', u'c', u'd'))
! test('join', ' ', u'w x y z', Sequence(u'wxyz'))
! test('join', ' ', TypeError, 7)
  
  result = u''