[Python-checkins] r85495 - in python/branches/py3k: Lib/doctest.py Lib/test/test_doctest.py Misc/NEWS

florent.xicluna python-checkins at python.org
Thu Oct 14 22:56:20 CEST 2010


Author: florent.xicluna
Date: Thu Oct 14 22:56:20 2010
New Revision: 85495

Log:
Fix the regex to match all kind of filenames, for interactive debugging in doctests. (issue #9409)



Modified:
   python/branches/py3k/Lib/doctest.py
   python/branches/py3k/Lib/test/test_doctest.py
   python/branches/py3k/Misc/NEWS

Modified: python/branches/py3k/Lib/doctest.py
==============================================================================
--- python/branches/py3k/Lib/doctest.py	(original)
+++ python/branches/py3k/Lib/doctest.py	Thu Oct 14 22:56:20 2010
@@ -1319,7 +1319,7 @@
         self.tries += t
 
     __LINECACHE_FILENAME_RE = re.compile(r'<doctest '
-                                         r'(?P<name>[\w\.]+)'
+                                         r'(?P<name>.+)'
                                          r'\[(?P<examplenum>\d+)\]>$')
     def __patched_linecache_getlines(self, filename, module_globals=None):
         m = self.__LINECACHE_FILENAME_RE.match(filename)

Modified: python/branches/py3k/Lib/test/test_doctest.py
==============================================================================
--- python/branches/py3k/Lib/test/test_doctest.py	(original)
+++ python/branches/py3k/Lib/test/test_doctest.py	Thu Oct 14 22:56:20 2010
@@ -1700,7 +1700,7 @@
       ... >>> import pdb; pdb.set_trace()
       ... '''
       >>> parser = doctest.DocTestParser()
-      >>> test = parser.get_doctest(doc, {}, "foo", "foo.py", 0)
+      >>> test = parser.get_doctest(doc, {}, "foo-bär at baz", "foo-bär at baz.py", 0)
       >>> runner = doctest.DocTestRunner(verbose=False)
 
     To demonstrate this, we'll create a fake standard input that
@@ -1716,7 +1716,7 @@
       >>> try: runner.run(test)
       ... finally: sys.stdin = real_stdin
       --Return--
-      > <doctest foo[1]>(1)<module>()->None
+      > <doctest foo-bär at baz[1]>(1)<module>()->None
       -> import pdb; pdb.set_trace()
       (Pdb) print(x)
       42
@@ -1733,7 +1733,7 @@
       ... >>> x=1
       ... >>> calls_set_trace()
       ... '''
-      >>> test = parser.get_doctest(doc, globals(), "foo", "foo.py", 0)
+      >>> test = parser.get_doctest(doc, globals(), "foo-bär at baz", "foo-bär at baz.py", 0)
       >>> real_stdin = sys.stdin
       >>> sys.stdin = _FakeInput([
       ...    'print(y)',  # print data defined in the function
@@ -1752,7 +1752,7 @@
       (Pdb) print(y)
       2
       (Pdb) up
-      > <doctest foo[1]>(1)<module>()
+      > <doctest foo-bär at baz[1]>(1)<module>()
       -> calls_set_trace()
       (Pdb) print(x)
       1
@@ -1770,7 +1770,7 @@
       ... ...     import pdb; pdb.set_trace()
       ... >>> f(3)
       ... '''
-      >>> test = parser.get_doctest(doc, globals(), "foo", "foo.py", 0)
+      >>> test = parser.get_doctest(doc, globals(), "foo-bär at baz", "foo-bär at baz.py", 0)
       >>> real_stdin = sys.stdin
       >>> sys.stdin = _FakeInput([
       ...    'list',     # list source from example 2
@@ -1784,7 +1784,7 @@
       ... finally: sys.stdin = real_stdin
       ... # doctest: +NORMALIZE_WHITESPACE
       --Return--
-      > <doctest foo[1]>(3)g()->None
+      > <doctest foo-bär at baz[1]>(3)g()->None
       -> import pdb; pdb.set_trace()
       (Pdb) list
         1     def g(x):
@@ -1793,7 +1793,7 @@
       [EOF]
       (Pdb) next
       --Return--
-      > <doctest foo[0]>(2)f()->None
+      > <doctest foo-bär at baz[0]>(2)f()->None
       -> g(x*2)
       (Pdb) list
         1     def f(x):
@@ -1801,14 +1801,14 @@
       [EOF]
       (Pdb) next
       --Return--
-      > <doctest foo[2]>(1)<module>()->None
+      > <doctest foo-bär at baz[2]>(1)<module>()->None
       -> f(3)
       (Pdb) list
         1  -> f(3)
       [EOF]
       (Pdb) continue
       **********************************************************************
-      File "foo.py", line 7, in foo
+      File "foo-bär at baz.py", line 7, in foo-bär at baz
       Failed example:
           f(3)
       Expected nothing
@@ -1842,7 +1842,7 @@
     ... '''
     >>> parser = doctest.DocTestParser()
     >>> runner = doctest.DocTestRunner(verbose=False)
-    >>> test = parser.get_doctest(doc, globals(), "foo", "foo.py", 0)
+    >>> test = parser.get_doctest(doc, globals(), "foo-bär at baz", "foo-bär at baz.py", 0)
     >>> real_stdin = sys.stdin
     >>> sys.stdin = _FakeInput([
     ...    'print(y)',  # print data defined in the function
@@ -1895,7 +1895,7 @@
     (Pdb) print(y)
     1
     (Pdb) up
-    > <doctest foo[1]>(1)<module>()
+    > <doctest foo-bär at baz[1]>(1)<module>()
     -> calls_set_trace()
     (Pdb) print(foo)
     *** NameError: name 'foo' is not defined

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Thu Oct 14 22:56:20 2010
@@ -21,6 +21,9 @@
 Library
 -------
 
+- Issue 9409: Fix the regex to match all kind of filenames, for interactive
+  debugging in doctests.
+
 - Issue 9183: ``datetime.timezone(datetime.timedelta(0))`` will now
   return the same instance as ``datetime.timezone.utc``.
 


More information about the Python-checkins mailing list