[Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.126,1.127 test_descrtut.py,1.11,1.12 test_generators.py,1.32,1.33 test_unicode.py,1.51,1.52

Guido van Rossum gvanrossum@users.sourceforge.net
Wed, 03 Apr 2002 14:41:52 -0800


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

Modified Files:
	test_descr.py test_descrtut.py test_generators.py 
	test_unicode.py 
Log Message:
Add the 'bool' type and its values 'False' and 'True', as described in
PEP 285.  Everything described in the PEP is here, and there is even
some documentation.  I had to fix 12 unit tests; all but one of these
were printing Boolean outcomes that changed from 0/1 to False/True.
(The exception is test_unicode.py, which did a type(x) == type(y)
style comparison.  I could've fixed that with a single line using
issubtype(x, type(y)), but instead chose to be explicit about those
places where a bool is expected.

Still to do: perhaps more documentation; change standard library
modules to return False/True from predicates.



Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v
retrieving revision 1.126
retrieving revision 1.127
diff -C2 -d -r1.126 -r1.127
*** test_descr.py	2 Apr 2002 17:53:47 -0000	1.126
--- test_descr.py	3 Apr 2002 22:41:50 -0000	1.127
***************
*** 2330,2334 ****
      def check(descr, what):
          vereq(descr.__doc__, what)
!     check(file.closed, "flag set if the file is closed") # getset descriptor
      check(file.name, "file name") # member descriptor
  
--- 2330,2334 ----
      def check(descr, what):
          vereq(descr.__doc__, what)
!     check(file.closed, "True if the file is closed") # getset descriptor
      check(file.name, "file name") # member descriptor
  

Index: test_descrtut.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descrtut.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** test_descrtut.py	19 Feb 2002 04:25:19 -0000	1.11
--- test_descrtut.py	3 Apr 2002 22:41:50 -0000	1.12
***************
*** 49,53 ****
      <class 'test.test_descrtut.defaultdict'>
      >>> print type(a) is a.__class__    # its type is its class
!     1
      >>> a[1] = 3.25                     # modify the instance
      >>> print a                         # show the new value
--- 49,53 ----
      <class 'test.test_descrtut.defaultdict'>
      >>> print type(a) is a.__class__    # its type is its class
!     True
      >>> a[1] = 3.25                     # modify the instance
      >>> print a                         # show the new value
***************
*** 99,103 ****
      -1000
      >>> 'default' in dir(a)
!     1
      >>> a.x1 = 100
      >>> a.x2 = 200
--- 99,103 ----
      -1000
      >>> 'default' in dir(a)
!     True
      >>> a.x1 = 100
      >>> a.x2 = 200
***************
*** 106,110 ****
      >>> d = dir(a)
      >>> 'default' in d and 'x1' in d and 'x2' in d
!     1
      >>> print a.__dict__
      {'default': -1000, 'x2': 200, 'x1': 100}
--- 106,110 ----
      >>> d = dir(a)
      >>> 'default' in d and 'x1' in d and 'x2' in d
!     True
      >>> print a.__dict__
      {'default': -1000, 'x2': 200, 'x1': 100}
***************
*** 168,176 ****
      <type 'list'>
      >>> isinstance([], list)
!     1
      >>> isinstance([], dict)
!     0
      >>> isinstance([], object)
!     1
      >>>
  
--- 168,176 ----
      <type 'list'>
      >>> isinstance([], list)
!     True
      >>> isinstance([], dict)
!     False
      >>> isinstance([], object)
!     True
      >>>
  

Index: test_generators.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_generators.py,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** test_generators.py	1 Apr 2002 00:28:59 -0000	1.32
--- test_generators.py	3 Apr 2002 22:41:50 -0000	1.33
***************
*** 387,394 ****
  x.next() -> the next value, or raise StopIteration
  >>> iter(i) is i
! 1
  >>> import types
  >>> isinstance(i, types.GeneratorType)
! 1
  
  And more, added later.
--- 387,394 ----
  x.next() -> the next value, or raise StopIteration
  >>> iter(i) is i
! True
  >>> import types
  >>> isinstance(i, types.GeneratorType)
! True
  
  And more, added later.
***************
*** 1219,1232 ****
  ...     all = list(gencopy(conjoin([lambda: iter((0, 1))] * n)))
  ...     print n, len(all), all[0] == [0] * n, all[-1] == [1] * n
! 0 1 1 1
! 1 2 1 1
! 2 4 1 1
! 3 8 1 1
! 4 16 1 1
! 5 32 1 1
! 6 64 1 1
! 7 128 1 1
! 8 256 1 1
! 9 512 1 1
  
  And run an 8-queens solver.
--- 1219,1232 ----
  ...     all = list(gencopy(conjoin([lambda: iter((0, 1))] * n)))
  ...     print n, len(all), all[0] == [0] * n, all[-1] == [1] * n
! 0 1 True True
! 1 2 True True
! 2 4 True True
! 3 8 True True
! 4 16 True True
! 5 32 True True
! 6 64 True True
! 7 128 True True
! 8 256 True True
! 9 512 True True
  
  And run an 8-queens solver.

Index: test_unicode.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode.py,v
retrieving revision 1.51
retrieving revision 1.52
diff -C2 -d -r1.51 -r1.52
*** test_unicode.py	29 Mar 2002 16:21:44 -0000	1.51
--- test_unicode.py	3 Apr 2002 22:41:50 -0000	1.52
***************
*** 168,199 ****
  test('replace', u'one!two!three!', u'one!two!three!', u'x', u'@', 2)
  
! test('startswith', u'hello', 1, u'he')
! test('startswith', u'hello', 1, u'hello')
! test('startswith', u'hello', 0, u'hello world')
! test('startswith', u'hello', 1, u'')
! test('startswith', u'hello', 0, u'ello')
! test('startswith', u'hello', 1, u'ello', 1)
! test('startswith', u'hello', 1, u'o', 4)
! test('startswith', u'hello', 0, u'o', 5)
! test('startswith', u'hello', 1, u'', 5)
! test('startswith', u'hello', 0, u'lo', 6)
! test('startswith', u'helloworld', 1, u'lowo', 3)
! test('startswith', u'helloworld', 1, u'lowo', 3, 7)
! test('startswith', u'helloworld', 0, u'lowo', 3, 6)
  
! test('endswith', u'hello', 1, u'lo')
! test('endswith', u'hello', 0, u'he')
! test('endswith', u'hello', 1, u'')
! test('endswith', u'hello', 0, u'hello world')
! test('endswith', u'helloworld', 0, u'worl')
! test('endswith', u'helloworld', 1, u'worl', 3, 9)
! test('endswith', u'helloworld', 1, u'world', 3, 12)
! test('endswith', u'helloworld', 1, u'lowo', 1, 7)
! test('endswith', u'helloworld', 1, u'lowo', 2, 7)
! test('endswith', u'helloworld', 1, u'lowo', 3, 7)
! test('endswith', u'helloworld', 0, u'lowo', 4, 7)
! test('endswith', u'helloworld', 0, u'lowo', 3, 8)
! test('endswith', u'ab', 0, u'ab', 0, 1)
! test('endswith', u'ab', 0, u'ab', 0, 0)
  
  test('expandtabs', u'abc\rab\tdef\ng\thi', u'abc\rab      def\ng       hi')
--- 168,199 ----
  test('replace', u'one!two!three!', u'one!two!three!', u'x', u'@', 2)
  
! test('startswith', u'hello', True, u'he')
! test('startswith', u'hello', True, u'hello')
! test('startswith', u'hello', False, u'hello world')
! test('startswith', u'hello', True, u'')
! test('startswith', u'hello', False, u'ello')
! test('startswith', u'hello', True, u'ello', 1)
! test('startswith', u'hello', True, u'o', 4)
! test('startswith', u'hello', False, u'o', 5)
! test('startswith', u'hello', True, u'', 5)
! test('startswith', u'hello', False, u'lo', 6)
! test('startswith', u'helloworld', True, u'lowo', 3)
! test('startswith', u'helloworld', True, u'lowo', 3, 7)
! test('startswith', u'helloworld', False, u'lowo', 3, 6)
  
! test('endswith', u'hello', True, u'lo')
! test('endswith', u'hello', False, u'he')
! test('endswith', u'hello', True, u'')
! test('endswith', u'hello', False, u'hello world')
! test('endswith', u'helloworld', False, u'worl')
! test('endswith', u'helloworld', True, u'worl', 3, 9)
! test('endswith', u'helloworld', True, u'world', 3, 12)
! test('endswith', u'helloworld', True, u'lowo', 1, 7)
! test('endswith', u'helloworld', True, u'lowo', 2, 7)
! test('endswith', u'helloworld', True, u'lowo', 3, 7)
! test('endswith', u'helloworld', False, u'lowo', 4, 7)
! test('endswith', u'helloworld', False, u'lowo', 3, 8)
! test('endswith', u'ab', False, u'ab', 0, 1)
! test('endswith', u'ab', False, u'ab', 0, 0)
  
  test('expandtabs', u'abc\rab\tdef\ng\thi', u'abc\rab      def\ng       hi')
***************
*** 287,334 ****
  test('center', u'abc', u'abc', 2)
  
! test('islower', u'a', 1)
! test('islower', u'A', 0)
! test('islower', u'\n', 0)
! test('islower', u'\u1FFc', 0)
! test('islower', u'abc', 1)
! test('islower', u'aBc', 0)
! test('islower', u'abc\n', 1)
  
! test('isupper', u'a', 0)
! test('isupper', u'A', 1)
! test('isupper', u'\n', 0)
  if sys.platform[:4] != 'java':
!     test('isupper', u'\u1FFc', 0)
! test('isupper', u'ABC', 1)
! test('isupper', u'AbC', 0)
! test('isupper', u'ABC\n', 1)
  
! test('istitle', u'a', 0)
! test('istitle', u'A', 1)
! test('istitle', u'\n', 0)
! test('istitle', u'\u1FFc', 1)
! test('istitle', u'A Titlecased Line', 1)
! test('istitle', u'A\nTitlecased Line', 1)
! test('istitle', u'A Titlecased, Line', 1)
! test('istitle', u'Greek \u1FFcitlecases ...', 1)
! test('istitle', u'Not a capitalized String', 0)
! test('istitle', u'Not\ta Titlecase String', 0)
! test('istitle', u'Not--a Titlecase String', 0)
  
! test('isalpha', u'a', 1)
! test('isalpha', u'A', 1)
! test('isalpha', u'\n', 0)
! test('isalpha', u'\u1FFc', 1)
! test('isalpha', u'abc', 1)
! test('isalpha', u'aBc123', 0)
! test('isalpha', u'abc\n', 0)
  
! test('isalnum', u'a', 1)
! test('isalnum', u'A', 1)
! test('isalnum', u'\n', 0)
! test('isalnum', u'123abc456', 1)
! test('isalnum', u'a1b3c', 1)
! test('isalnum', u'aBc000 ', 0)
! test('isalnum', u'abc\n', 0)
  
  test('splitlines', u"abc\ndef\n\rghi", [u'abc', u'def', u'', u'ghi'])
--- 287,334 ----
  test('center', u'abc', u'abc', 2)
  
! test('islower', u'a', True)
! test('islower', u'A', False)
! test('islower', u'\n', False)
! test('islower', u'\u1FFc', False)
! test('islower', u'abc', True)
! test('islower', u'aBc', False)
! test('islower', u'abc\n', True)
  
! test('isupper', u'a', False)
! test('isupper', u'A', True)
! test('isupper', u'\n', False)
  if sys.platform[:4] != 'java':
!     test('isupper', u'\u1FFc', False)
! test('isupper', u'ABC', True)
! test('isupper', u'AbC', False)
! test('isupper', u'ABC\n', True)
  
! test('istitle', u'a', False)
! test('istitle', u'A', True)
! test('istitle', u'\n', False)
! test('istitle', u'\u1FFc', True)
! test('istitle', u'A Titlecased Line', True)
! test('istitle', u'A\nTitlecased Line', True)
! test('istitle', u'A Titlecased, Line', True)
! test('istitle', u'Greek \u1FFcitlecases ...', True)
! test('istitle', u'Not a capitalized String', False)
! test('istitle', u'Not\ta Titlecase String', False)
! test('istitle', u'Not--a Titlecase String', False)
  
! test('isalpha', u'a', True)
! test('isalpha', u'A', True)
! test('isalpha', u'\n', False)
! test('isalpha', u'\u1FFc', True)
! test('isalpha', u'abc', True)
! test('isalpha', u'aBc123', False)
! test('isalpha', u'abc\n', False)
  
! test('isalnum', u'a', True)
! test('isalnum', u'A', True)
! test('isalnum', u'\n', False)
! test('isalnum', u'123abc456', True)
! test('isalnum', u'a1b3c', True)
! test('isalnum', u'aBc000 ', False)
! test('isalnum', u'abc\n', False)
  
  test('splitlines', u"abc\ndef\n\rghi", [u'abc', u'def', u'', u'ghi'])
***************
*** 338,342 ****
  test('splitlines', u"abc\ndef\r\nghi\n\r", [u'abc', u'def', u'ghi', u''])
  test('splitlines', u"\nabc\ndef\r\nghi\n\r", [u'', u'abc', u'def', u'ghi', u''])
! test('splitlines', u"\nabc\ndef\r\nghi\n\r", [u'\n', u'abc\n', u'def\r\n', u'ghi\n', u'\r'], 1)
  
  test('translate', u"abababc", u'bbbc', {ord('a'):None})
--- 338,342 ----
  test('splitlines', u"abc\ndef\r\nghi\n\r", [u'abc', u'def', u'ghi', u''])
  test('splitlines', u"\nabc\ndef\r\nghi\n\r", [u'', u'abc', u'def', u'ghi', u''])
! test('splitlines', u"\nabc\ndef\r\nghi\n\r", [u'\n', u'abc\n', u'def\r\n', u'ghi\n', u'\r'], True)
  
  test('translate', u"abababc", u'bbbc', {ord('a'):None})