1- # Module doctest version 0.9.6
1+ # Module doctest version 0.9.7
22# Released to the public domain 16-Jan-2001,
33# by Tim Peters ([email protected] ). 44
@@ -345,6 +345,8 @@ def _test():
345345# examples no longer worked *exactly* as advertised, due to minor
346346# language changes, and running doctest on itself pointed that out.
347347# Hard to think of a better example of why this is useful <wink>.
348+ # 0,9,7 9-Feb-2001
349+ # string method conversion
348350
349351__version__ = 0 , 9 , 6
350352
@@ -355,13 +357,6 @@ def _test():
355357_StringType = types .StringType
356358del types
357359
358- import string
359- _string_find = string .find
360- _string_join = string .join
361- _string_split = string .split
362- _string_rindex = string .rindex
363- del string
364-
365360import re
366361PS1 = ">>>"
367362PS2 = "..."
@@ -384,7 +379,7 @@ def _extract_examples(s):
384379 isPS1 , isPS2 = _isPS1 , _isPS2
385380 isEmpty , isComment = _isEmpty , _isComment
386381 examples = []
387- lines = _string_split ( s , "\n " )
382+ lines = s . split ( "\n " )
388383 i , n = 0 , len (lines )
389384 while i < n :
390385 line = lines [i ]
@@ -422,7 +417,7 @@ def _extract_examples(s):
422417 # get rid of useless null line from trailing empty "..."
423418 if source [- 1 ] == "" :
424419 del source [- 1 ]
425- source = _string_join ( source , "\n " ) + "\n "
420+ source = "\n " . join ( source ) + "\n "
426421 # suck up response
427422 if isPS1 (line ) or isEmpty (line ):
428423 expect = ""
@@ -437,7 +432,7 @@ def _extract_examples(s):
437432 line = lines [i ]
438433 if isPS1 (line ) or isEmpty (line ):
439434 break
440- expect = _string_join ( expect , "\n " ) + "\n "
435+ expect = "\n " . join ( expect ) + "\n "
441436 examples .append ( (source , expect , lineno ) )
442437 return examples
443438
@@ -449,7 +444,7 @@ def __init__(self):
449444 def write (self , s ):
450445 self .buf .append (s )
451446 def get (self ):
452- return _string_join (self .buf , "" )
447+ return "" . join (self .buf )
453448 def clear (self ):
454449 self .buf = []
455450 def flush (self ):
@@ -464,7 +459,7 @@ def _tag_out(printer, *tag_msg_pairs):
464459 printer (tag + ":" )
465460 msg_has_nl = msg [- 1 :] == "\n "
466461 msg_has_two_nl = msg_has_nl and \
467- _string_find ( msg , "\n " ) < len (msg ) - 1
462+ msg . find ( "\n " ) < len (msg ) - 1
468463 if len (tag ) + len (msg ) < 76 and not msg_has_two_nl :
469464 printer (" " )
470465 else :
@@ -494,10 +489,10 @@ def _run_examples_inner(out, fakeout, examples, globs, verbose, name):
494489 state = OK
495490 except :
496491 # See whether the exception was expected.
497- if _string_find ( want , "Traceback (innermost last):\n " ) == 0 :
492+ if want . find ( "Traceback (innermost last):\n " ) == 0 :
498493 # Only compare exception type and value - the rest of
499494 # the traceback isn't necessary.
500- want = _string_split ( want , '\n ' )[- 2 ] + '\n '
495+ want = want . split ( '\n ' )[- 2 ] + '\n '
501496 exc_type , exc_val , exc_tb = sys .exc_info ()
502497 got = traceback .format_exception_only (exc_type , exc_val )[0 ]
503498 state = OK
@@ -960,7 +955,7 @@ def __record_outcome(self, name, f, t):
960955
961956 def __runone (self , target , name ):
962957 if "." in name :
963- i = _string_rindex ( name , "." )
958+ i = name . rindex ( "." )
964959 prefix , base = name [:i ], name [i + 1 :]
965960 else :
966961 prefix , base = "" , base
0 commit comments