[Python-checkins] CVS: python/dist/src/Lib doctest.py,1.2,1.3
Eric S. Raymond
esr@users.sourceforge.net
Fri, 09 Feb 2001 00:33:46 -0800
Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv21013
Modified Files:
doctest.py
Log Message:
String method conversion.
Index: doctest.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** doctest.py 2001/01/20 23:34:12 1.2
--- doctest.py 2001/02/09 08:33:43 1.3
***************
*** 1,3 ****
! # Module doctest version 0.9.6
# Released to the public domain 16-Jan-2001,
# by Tim Peters (tim.one@home.com).
--- 1,3 ----
! # Module doctest version 0.9.7
# Released to the public domain 16-Jan-2001,
# by Tim Peters (tim.one@home.com).
***************
*** 346,349 ****
--- 346,351 ----
# language changes, and running doctest on itself pointed that out.
# Hard to think of a better example of why this is useful <wink>.
+ # 0,9,7 9-Feb-2001
+ # string method conversion
__version__ = 0, 9, 6
***************
*** 356,366 ****
del types
- import string
- _string_find = string.find
- _string_join = string.join
- _string_split = string.split
- _string_rindex = string.rindex
- del string
-
import re
PS1 = ">>>"
--- 358,361 ----
***************
*** 385,389 ****
isEmpty, isComment = _isEmpty, _isComment
examples = []
! lines = _string_split(s, "\n")
i, n = 0, len(lines)
while i < n:
--- 380,384 ----
isEmpty, isComment = _isEmpty, _isComment
examples = []
! lines = s.split("\n")
i, n = 0, len(lines)
while i < n:
***************
*** 423,427 ****
if source[-1] == "":
del source[-1]
! source = _string_join(source, "\n") + "\n"
# suck up response
if isPS1(line) or isEmpty(line):
--- 418,422 ----
if source[-1] == "":
del source[-1]
! source = "\n".join(source) + "\n"
# suck up response
if isPS1(line) or isEmpty(line):
***************
*** 438,442 ****
if isPS1(line) or isEmpty(line):
break
! expect = _string_join(expect, "\n") + "\n"
examples.append( (source, expect, lineno) )
return examples
--- 433,437 ----
if isPS1(line) or isEmpty(line):
break
! expect = "\n".join(expect) + "\n"
examples.append( (source, expect, lineno) )
return examples
***************
*** 450,454 ****
self.buf.append(s)
def get(self):
! return _string_join(self.buf, "")
def clear(self):
self.buf = []
--- 445,449 ----
self.buf.append(s)
def get(self):
! return "".join(self.buf)
def clear(self):
self.buf = []
***************
*** 465,469 ****
msg_has_nl = msg[-1:] == "\n"
msg_has_two_nl = msg_has_nl and \
! _string_find(msg, "\n") < len(msg) - 1
if len(tag) + len(msg) < 76 and not msg_has_two_nl:
printer(" ")
--- 460,464 ----
msg_has_nl = msg[-1:] == "\n"
msg_has_two_nl = msg_has_nl and \
! msg.find("\n") < len(msg) - 1
if len(tag) + len(msg) < 76 and not msg_has_two_nl:
printer(" ")
***************
*** 495,502 ****
except:
# See whether the exception was expected.
! if _string_find(want, "Traceback (innermost last):\n") == 0:
# Only compare exception type and value - the rest of
# the traceback isn't necessary.
! want = _string_split(want, '\n')[-2] + '\n'
exc_type, exc_val, exc_tb = sys.exc_info()
got = traceback.format_exception_only(exc_type, exc_val)[0]
--- 490,497 ----
except:
# See whether the exception was expected.
! if want.find("Traceback (innermost last):\n") == 0:
# Only compare exception type and value - the rest of
# the traceback isn't necessary.
! want = want.split('\n')[-2] + '\n'
exc_type, exc_val, exc_tb = sys.exc_info()
got = traceback.format_exception_only(exc_type, exc_val)[0]
***************
*** 961,965 ****
def __runone(self, target, name):
if "." in name:
! i = _string_rindex(name, ".")
prefix, base = name[:i], name[i+1:]
else:
--- 956,960 ----
def __runone(self, target, name):
if "." in name:
! i = name.rindex(".")
prefix, base = name[:i], name[i+1:]
else: