本文整理汇总了Python中doctest.debug_src方法的典型用法代码示例。如果您正苦于以下问题:Python doctest.debug_src方法的具体用法?Python doctest.debug_src怎么用?Python doctest.debug_src使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类doctest
的用法示例。
在下文中一共展示了doctest.debug_src方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_debug
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import debug_src [as 别名]
def test_debug(): r"""
Create a docstring that we want to debug:
>>> s = '''
... >>> x = 12
... >>> print x
... 12
... '''
Create some fake stdin input, to feed to the debugger:
>>> import tempfile
>>> real_stdin = sys.stdin
>>> sys.stdin = _FakeInput(['next', 'print x', 'continue'])
Run the debugger on the docstring, and then restore sys.stdin.
>>> try: doctest.debug_src(s)
... finally: sys.stdin = real_stdin
> <string>(1)<module>()
(Pdb) next
12
--Return--
> <string>(1)<module>()->None
(Pdb) print x
12
(Pdb) continue
"""
示例2: test_debug
# 需要导入模块: import doctest [as 别名]
# 或者: from doctest import debug_src [as 别名]
def test_debug(): r"""
Create a docstring that we want to debug:
>>> s = '''
... >>> x = 12
... >>> print(x)
... 12
... '''
Create some fake stdin input, to feed to the debugger:
>>> real_stdin = sys.stdin
>>> sys.stdin = _FakeInput(['next', 'print(x)', 'continue'])
Run the debugger on the docstring, and then restore sys.stdin.
>>> try: doctest.debug_src(s)
... finally: sys.stdin = real_stdin
> <string>(1)<module>()
(Pdb) next
12
--Return--
> <string>(1)<module>()->None
(Pdb) print(x)
12
(Pdb) continue
"""