Merged revisions 85495 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r85495 | florent.xicluna | 2010-10-14 22:56:20 +0200 (jeu., 14 oct. 2010) | 3 lines

  Fix the regex to match all kind of filenames, for interactive debugging in doctests. (issue #9409)
........
This commit is contained in:
Florent Xicluna 2010-10-14 21:10:45 +00:00
parent 8299393122
commit b67660fcce
3 changed files with 15 additions and 12 deletions

View File

@ -1327,7 +1327,7 @@ class DocTestRunner:
self.tries += t self.tries += t
__LINECACHE_FILENAME_RE = re.compile(r'<doctest ' __LINECACHE_FILENAME_RE = re.compile(r'<doctest '
r'(?P<name>[\w\.]+)' r'(?P<name>.+)'
r'\[(?P<examplenum>\d+)\]>$') r'\[(?P<examplenum>\d+)\]>$')
def __patched_linecache_getlines(self, filename, module_globals=None): def __patched_linecache_getlines(self, filename, module_globals=None):
m = self.__LINECACHE_FILENAME_RE.match(filename) m = self.__LINECACHE_FILENAME_RE.match(filename)

View File

@ -1724,7 +1724,7 @@ def test_pdb_set_trace():
... >>> import pdb; pdb.set_trace() ... >>> import pdb; pdb.set_trace()
... ''' ... '''
>>> parser = doctest.DocTestParser() >>> parser = doctest.DocTestParser()
>>> test = parser.get_doctest(doc, {}, "foo", "foo.py", 0) >>> test = parser.get_doctest(doc, {}, "foo-bär@baz", "foo-bär@baz.py", 0)
>>> runner = doctest.DocTestRunner(verbose=False) >>> runner = doctest.DocTestRunner(verbose=False)
To demonstrate this, we'll create a fake standard input that To demonstrate this, we'll create a fake standard input that
@ -1740,7 +1740,7 @@ def test_pdb_set_trace():
>>> try: runner.run(test) >>> try: runner.run(test)
... finally: sys.stdin = real_stdin ... finally: sys.stdin = real_stdin
--Return-- --Return--
> <doctest foo[1]>(1)<module>()->None > <doctest foo-bär@baz[1]>(1)<module>()->None
-> import pdb; pdb.set_trace() -> import pdb; pdb.set_trace()
(Pdb) print x (Pdb) print x
42 42
@ -1757,7 +1757,7 @@ def test_pdb_set_trace():
... >>> x=1 ... >>> x=1
... >>> calls_set_trace() ... >>> calls_set_trace()
... ''' ... '''
>>> test = parser.get_doctest(doc, globals(), "foo", "foo.py", 0) >>> test = parser.get_doctest(doc, globals(), "foo-bär@baz", "foo-bär@baz.py", 0)
>>> real_stdin = sys.stdin >>> real_stdin = sys.stdin
>>> sys.stdin = _FakeInput([ >>> sys.stdin = _FakeInput([
... 'print y', # print data defined in the function ... 'print y', # print data defined in the function
@ -1776,7 +1776,7 @@ def test_pdb_set_trace():
(Pdb) print y (Pdb) print y
2 2
(Pdb) up (Pdb) up
> <doctest foo[1]>(1)<module>() > <doctest foo-bär@baz[1]>(1)<module>()
-> calls_set_trace() -> calls_set_trace()
(Pdb) print x (Pdb) print x
1 1
@ -1794,7 +1794,7 @@ def test_pdb_set_trace():
... ... import pdb; pdb.set_trace() ... ... import pdb; pdb.set_trace()
... >>> f(3) ... >>> f(3)
... ''' ... '''
>>> test = parser.get_doctest(doc, globals(), "foo", "foo.py", 0) >>> test = parser.get_doctest(doc, globals(), "foo-bär@baz", "foo-bär@baz.py", 0)
>>> real_stdin = sys.stdin >>> real_stdin = sys.stdin
>>> sys.stdin = _FakeInput([ >>> sys.stdin = _FakeInput([
... 'list', # list source from example 2 ... 'list', # list source from example 2
@ -1808,7 +1808,7 @@ def test_pdb_set_trace():
... finally: sys.stdin = real_stdin ... finally: sys.stdin = real_stdin
... # doctest: +NORMALIZE_WHITESPACE ... # doctest: +NORMALIZE_WHITESPACE
--Return-- --Return--
> <doctest foo[1]>(3)g()->None > <doctest foo-bär@baz[1]>(3)g()->None
-> import pdb; pdb.set_trace() -> import pdb; pdb.set_trace()
(Pdb) list (Pdb) list
1 def g(x): 1 def g(x):
@ -1817,7 +1817,7 @@ def test_pdb_set_trace():
[EOF] [EOF]
(Pdb) next (Pdb) next
--Return-- --Return--
> <doctest foo[0]>(2)f()->None > <doctest foo-bär@baz[0]>(2)f()->None
-> g(x*2) -> g(x*2)
(Pdb) list (Pdb) list
1 def f(x): 1 def f(x):
@ -1825,14 +1825,14 @@ def test_pdb_set_trace():
[EOF] [EOF]
(Pdb) next (Pdb) next
--Return-- --Return--
> <doctest foo[2]>(1)<module>()->None > <doctest foo-bär@baz[2]>(1)<module>()->None
-> f(3) -> f(3)
(Pdb) list (Pdb) list
1 -> f(3) 1 -> f(3)
[EOF] [EOF]
(Pdb) continue (Pdb) continue
********************************************************************** **********************************************************************
File "foo.py", line 7, in foo File "foo-bär@baz.py", line 7, in foo-bär@baz
Failed example: Failed example:
f(3) f(3)
Expected nothing Expected nothing
@ -1866,7 +1866,7 @@ def test_pdb_set_trace_nested():
... ''' ... '''
>>> parser = doctest.DocTestParser() >>> parser = doctest.DocTestParser()
>>> runner = doctest.DocTestRunner(verbose=False) >>> runner = doctest.DocTestRunner(verbose=False)
>>> test = parser.get_doctest(doc, globals(), "foo", "foo.py", 0) >>> test = parser.get_doctest(doc, globals(), "foo-bär@baz", "foo-bär@baz.py", 0)
>>> real_stdin = sys.stdin >>> real_stdin = sys.stdin
>>> sys.stdin = _FakeInput([ >>> sys.stdin = _FakeInput([
... 'print y', # print data defined in the function ... 'print y', # print data defined in the function
@ -1918,7 +1918,7 @@ def test_pdb_set_trace_nested():
(Pdb) print y (Pdb) print y
1 1
(Pdb) up (Pdb) up
> <doctest foo[1]>(1)<module>() > <doctest foo-bär@baz[1]>(1)<module>()
-> calls_set_trace() -> calls_set_trace()
(Pdb) print foo (Pdb) print foo
*** NameError: name 'foo' is not defined *** NameError: name 'foo' is not defined

View File

@ -51,6 +51,9 @@ Core and Builtins
Library Library
------- -------
- Issue 9409: Fix the regex to match all kind of filenames, for interactive
debugging in doctests.
- Issue #6612: Fix site and sysconfig to catch os.getcwd() error, eg. if the - Issue #6612: Fix site and sysconfig to catch os.getcwd() error, eg. if the
current directory was deleted. Patch written by W. Trevor King. current directory was deleted. Patch written by W. Trevor King.