[Python-checkins] python/dist/src/Lib/test string_tests.py,1.19,1.20 test_contains.py,1.9,1.10 test_string.py,1.18,1.19 test_unicode.py,1.60,1.61 test_userstring.py,1.7,1.8

bwarsaw@users.sourceforge.net bwarsaw@users.sourceforge.net
Tue, 06 Aug 2002 09:58:23 -0700


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

Modified Files:
	string_tests.py test_contains.py test_string.py 
	test_unicode.py test_userstring.py 
Log Message:
Committing patch #591250 which provides "str1 in str2" when str1 is a
string of longer than 1 character.


Index: string_tests.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/string_tests.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** string_tests.py	30 Jul 2002 23:26:00 -0000	1.19
--- string_tests.py	6 Aug 2002 16:58:20 -0000	1.20
***************
*** 2,6 ****
  
  import string
! from test.test_support import verify, verbose, TestFailed, have_unicode
  
  transtable = '\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037 !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`xyzdefghijklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377'
--- 2,6 ----
  
  import string
! from test.test_support import verify, vereq, verbose, TestFailed, have_unicode
  
  transtable = '\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037 !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`xyzdefghijklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377'
***************
*** 296,297 ****
--- 296,317 ----
          verify('hello world'.encode('zlib') == data)
          verify(data.decode('zlib') == 'hello world')
+ 
+ def test_exception(lhs, rhs, msg):
+     try:
+         lhs in rhs
+     except TypeError:
+         pass
+     else:
+         raise TestFailed, msg
+ 
+ def run_contains_tests(test):
+     vereq('' in '', True)
+     vereq('' in 'abc', True)
+     vereq('\0' in 'abc', False)
+     vereq('\0' in '\0abc', True)
+     vereq('\0' in 'abc\0', True)
+     vereq('a' in '\0abc', True)
+     vereq('asdf' in 'asdf', True)
+     vereq('asdf' in 'asd', False)
+     vereq('asdf' in '', False)
+ 

Index: test_contains.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_contains.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** test_contains.py	30 Jul 2002 23:26:01 -0000	1.9
--- test_contains.py	6 Aug 2002 16:58:20 -0000	1.10
***************
*** 46,60 ****
  check('d' not in 'abc', "'d' in 'abc'")
  
! try:
!     '' in 'abc'
!     check(0, "'' in 'abc' did not raise error")
! except TypeError:
!     pass
! 
! try:
!     'ab' in 'abc'
!     check(0, "'ab' in 'abc' did not raise error")
! except TypeError:
!     pass
  
  try:
--- 46,51 ----
  check('d' not in 'abc', "'d' in 'abc'")
  
! check('' in '', "'' not in ''")
! check('' in 'abc', "'' not in 'abc'")
  
  try:
***************
*** 72,86 ****
      check('d' not in unicode('abc'), "'d' in u'abc'")
  
!     try:
!         '' in unicode('abc')
!         check(0, "'' in u'abc' did not raise error")
!     except TypeError:
!         pass
! 
!     try:
!         'ab' in unicode('abc')
!         check(0, "'ab' in u'abc' did not raise error")
!     except TypeError:
!         pass
  
      try:
--- 63,72 ----
      check('d' not in unicode('abc'), "'d' in u'abc'")
  
!     check('' in unicode(''), "'' not in u''")
!     check(unicode('') in '', "u'' not in ''")
!     check(unicode('') in unicode(''), "u'' not in u''")
!     check('' in unicode('abc'), "'' not in u'abc'")
!     check(unicode('') in 'abc', "u'' not in 'abc'")
!     check(unicode('') in unicode('abc'), "u'' not in u'abc'")
  
      try:
***************
*** 95,126 ****
      check(unicode('d') not in unicode('abc'), "u'd' in u'abc'")
  
-     try:
-         unicode('') in unicode('abc')
-         check(0, "u'' in u'abc' did not raise error")
-     except TypeError:
-         pass
- 
-     try:
-         unicode('ab') in unicode('abc')
-         check(0, "u'ab' in u'abc' did not raise error")
-     except TypeError:
-         pass
- 
      # Test Unicode char in string
  
      check(unicode('c') in 'abc', "u'c' not in 'abc'")
      check(unicode('d') not in 'abc', "u'd' in 'abc'")
- 
-     try:
-         unicode('') in 'abc'
-         check(0, "u'' in 'abc' did not raise error")
-     except TypeError:
-         pass
- 
-     try:
-         unicode('ab') in 'abc'
-         check(0, "u'ab' in 'abc' did not raise error")
-     except TypeError:
-         pass
  
  # A collection of tests on builtin sequence types
--- 81,88 ----

Index: test_string.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_string.py,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** test_string.py	23 Jul 2002 19:04:04 -0000	1.18
--- test_string.py	6 Aug 2002 16:58:20 -0000	1.19
***************
*** 52,55 ****
--- 52,56 ----
  string_tests.run_module_tests(test)
  string_tests.run_method_tests(test)
+ string_tests.run_contains_tests(test)
  
  string.whitespace

Index: test_unicode.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode.py,v
retrieving revision 1.60
retrieving revision 1.61
diff -C2 -d -r1.60 -r1.61
*** test_unicode.py	4 Aug 2002 17:28:33 -0000	1.60
--- test_unicode.py	6 Aug 2002 16:58:20 -0000	1.61
***************
*** 7,11 ****
  
  """#"
! from test.test_support import verify, verbose, TestFailed
  import sys, string
  
--- 7,11 ----
  
  """#"
! from test.test_support import verify, vereq, verbose, TestFailed
  import sys, string
  
***************
*** 397,417 ****
  # Contains:
  print 'Testing Unicode contains method...',
! verify(('a' in u'abdb') == 1)
! verify(('a' in u'bdab') == 1)
! verify(('a' in u'bdaba') == 1)
! verify(('a' in u'bdba') == 1)
! verify(('a' in u'bdba') == 1)
! verify((u'a' in u'bdba') == 1)
! verify((u'a' in u'bdb') == 0)
! verify((u'a' in 'bdb') == 0)
! verify((u'a' in 'bdba') == 1)
! verify((u'a' in ('a',1,None)) == 1)
! verify((u'a' in (1,None,'a')) == 1)
! verify((u'a' in (1,None,u'a')) == 1)
! verify(('a' in ('a',1,None)) == 1)
! verify(('a' in (1,None,'a')) == 1)
! verify(('a' in (1,None,u'a')) == 1)
! verify(('a' in ('x',1,u'y')) == 0)
! verify(('a' in ('x',1,None)) == 0)
  print 'done.'
  
--- 397,417 ----
  # Contains:
  print 'Testing Unicode contains method...',
! vereq(('a' in u'abdb'), True)
! vereq(('a' in u'bdab'), True)
! vereq(('a' in u'bdaba'), True)
! vereq(('a' in u'bdba'), True)
! vereq(('a' in u'bdba'), True)
! vereq((u'a' in u'bdba'), True)
! vereq((u'a' in u'bdb'), False)
! vereq((u'a' in 'bdb'), False)
! vereq((u'a' in 'bdba'), True)
! vereq((u'a' in ('a',1,None)), True)
! vereq((u'a' in (1,None,'a')), True)
! vereq((u'a' in (1,None,u'a')), True)
! vereq(('a' in ('a',1,None)), True)
! vereq(('a' in (1,None,'a')), True)
! vereq(('a' in (1,None,u'a')), True)
! vereq(('a' in ('x',1,u'y')), False)
! vereq(('a' in ('x',1,None)), False)
  print 'done.'
  
***************
*** 759,760 ****
--- 759,799 ----
  print u'def\n'
  print 'done.'
+ 
+ def test_exception(lhs, rhs, msg):
+     try:
+         lhs in rhs
+     except TypeError:
+         pass
+     else:
+         raise TestFailed, msg
+ 
+ def run_contains_tests():
+     vereq(u'' in '', True)
+     vereq('' in u'', True)
+     vereq(u'' in u'', True)
+     vereq(u'' in 'abc', True)
+     vereq('' in u'abc', True)
+     vereq(u'' in u'abc', True)
+     vereq(u'\0' in 'abc', False)
+     vereq('\0' in u'abc', False)
+     vereq(u'\0' in u'abc', False)
+     vereq(u'\0' in '\0abc', True)
+     vereq('\0' in u'\0abc', True)
+     vereq(u'\0' in u'\0abc', True)
+     vereq(u'\0' in 'abc\0', True)
+     vereq('\0' in u'abc\0', True)
+     vereq(u'\0' in u'abc\0', True)
+     vereq(u'a' in '\0abc', True)
+     vereq('a' in u'\0abc', True)
+     vereq(u'a' in u'\0abc', True)
+     vereq(u'asdf' in 'asdf', True)
+     vereq('asdf' in u'asdf', True)
+     vereq(u'asdf' in u'asdf', True)
+     vereq(u'asdf' in 'asd', False)
+     vereq('asdf' in u'asd', False)
+     vereq(u'asdf' in u'asd', False)
+     vereq(u'asdf' in '', False)
+     vereq('asdf' in u'', False)
+     vereq(u'asdf' in u'', False)
+ 
+ run_contains_tests()

Index: test_userstring.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_userstring.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** test_userstring.py	23 Jul 2002 19:04:09 -0000	1.7
--- test_userstring.py	6 Aug 2002 16:58:20 -0000	1.8
***************
*** 42,43 ****
--- 42,44 ----
  
  string_tests.run_method_tests(test)
+ string_tests.run_contains_tests(test)