[Python-checkins] python/dist/src/Lib doctest.py,1.66,1.67

tim_one at users.sourceforge.net tim_one at users.sourceforge.net
Thu Aug 19 08:49:35 CEST 2004


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3017/Lib

Modified Files:
	doctest.py 
Log Message:
ELLIPSIS implementation:  an ellipsis couldn't match nothing if it
appeared at the end of a line.  Repaired that.  Also noted that it's
too easy to provoke this implementation into requiring exponential
time, and especially when a test fails.  I'll replace the implementation
with an always-efficient one later.


Index: doctest.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v
retrieving revision 1.66
retrieving revision 1.67
diff -C2 -d -r1.66 -r1.67
*** doctest.py	17 Aug 2004 16:37:12 -0000	1.66
--- doctest.py	19 Aug 2004 06:49:33 -0000	1.67
***************
*** 1469,1473 ****
          # contents of whitespace strings.  Note that this can be used
          # in conjunction with the ELLISPIS flag.
!         if (optionflags & NORMALIZE_WHITESPACE):
              got = ' '.join(got.split())
              want = ' '.join(want.split())
--- 1469,1473 ----
          # contents of whitespace strings.  Note that this can be used
          # in conjunction with the ELLISPIS flag.
!         if optionflags & NORMALIZE_WHITESPACE:
              got = ' '.join(got.split())
              want = ' '.join(want.split())
***************
*** 1478,1485 ****
          # match any substring in `got`.  We implement this by
          # transforming `want` into a regular expression.
!         if (optionflags & ELLIPSIS):
              # Escape any special regexp characters
!             want_re = re.escape(want)
!             # Replace ellipsis markers ('...') with .*
              want_re = want_re.replace(re.escape(ELLIPSIS_MARKER), '.*')
              # Require that it matches the entire string; and set the
--- 1478,1489 ----
          # match any substring in `got`.  We implement this by
          # transforming `want` into a regular expression.
!         if optionflags & ELLIPSIS:
!             # Remove \n from ...\n, else the newline will be required,
!             # and (for example) ... on a line by itself can't match
!             # nothing gracefully.
!             want_re = want.replace(ELLIPSIS_MARKER + '\n', ELLIPSIS_MARKER)
              # Escape any special regexp characters
!             want_re = re.escape(want_re)
!             # Replace escaped ellipsis markers ('\.\.\.') with .*
              want_re = want_re.replace(re.escape(ELLIPSIS_MARKER), '.*')
              # Require that it matches the entire string; and set the



More information about the Python-checkins mailing list