当前位置: 首页>>代码示例>>Python>>正文


Python FormattedExcinfo.repr_traceback方法代码示例

本文整理汇总了Python中py._code.code.FormattedExcinfo.repr_traceback方法的典型用法代码示例。如果您正苦于以下问题:Python FormattedExcinfo.repr_traceback方法的具体用法?Python FormattedExcinfo.repr_traceback怎么用?Python FormattedExcinfo.repr_traceback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在py._code.code.FormattedExcinfo的用法示例。


在下文中一共展示了FormattedExcinfo.repr_traceback方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_repr_traceback_tbfilter

# 需要导入模块: from py._code.code import FormattedExcinfo [as 别名]
# 或者: from py._code.code.FormattedExcinfo import repr_traceback [as 别名]
 def test_repr_traceback_tbfilter(self, importasmod):
     mod = importasmod("""
         def f(x):
             raise ValueError(x)
         def entry():
             f(0)
     """)
     excinfo = py.test.raises(ValueError, mod.entry)
     p = FormattedExcinfo(tbfilter=True)
     reprtb = p.repr_traceback(excinfo)
     assert len(reprtb.reprentries) == 2
     p = FormattedExcinfo(tbfilter=False)
     reprtb = p.repr_traceback(excinfo)
     assert len(reprtb.reprentries) == 3
开发者ID:Eleanor66613,项目名称:CS249-midterm,代码行数:16,代码来源:test_excinfo.py

示例2: test_repr_traceback_with_invalid_cwd

# 需要导入模块: from py._code.code import FormattedExcinfo [as 别名]
# 或者: from py._code.code.FormattedExcinfo import repr_traceback [as 别名]
    def test_repr_traceback_with_invalid_cwd(self, importasmod, monkeypatch):
        mod = importasmod("""
            def f(x):
                raise ValueError(x)
            def entry():
                f(0)
        """)
        excinfo = py.test.raises(ValueError, mod.entry)

        p = FormattedExcinfo()
        def raiseos():
            raise OSError(2)
        monkeypatch.setattr(py.std.os, 'getcwd', raiseos)
        assert p._makepath(__file__) == __file__
        reprtb = p.repr_traceback(excinfo)
开发者ID:Eleanor66613,项目名称:CS249-midterm,代码行数:17,代码来源:test_excinfo.py

示例3: test_repr_traceback_recursion

# 需要导入模块: from py._code.code import FormattedExcinfo [as 别名]
# 或者: from py._code.code.FormattedExcinfo import repr_traceback [as 别名]
    def test_repr_traceback_recursion(self, importasmod):
        mod = importasmod("""
            def rec2(x):
                return rec1(x+1)
            def rec1(x):
                return rec2(x-1)
            def entry():
                rec1(42)
        """)
        excinfo = py.test.raises(RuntimeError, mod.entry)

        for style in ("short", "long", "no"):
            p = FormattedExcinfo(style="short")
            reprtb = p.repr_traceback(excinfo)
            assert reprtb.extraline == "!!! Recursion detected (same locals & position)"
            assert str(reprtb)
开发者ID:Eleanor66613,项目名称:CS249-midterm,代码行数:18,代码来源:test_excinfo.py

示例4: test_repr_traceback_and_excinfo

# 需要导入模块: from py._code.code import FormattedExcinfo [as 别名]
# 或者: from py._code.code.FormattedExcinfo import repr_traceback [as 别名]
    def test_repr_traceback_and_excinfo(self, importasmod):
        mod = importasmod("""
            def f(x):
                raise ValueError(x)
            def entry():
                f(0)
        """)
        excinfo = py.test.raises(ValueError, mod.entry)

        for style in ("long", "short"):
            p = FormattedExcinfo(style=style)
            reprtb = p.repr_traceback(excinfo)
            assert len(reprtb.reprentries) == 2
            assert reprtb.style == style
            assert not reprtb.extraline
            repr = p.repr_excinfo(excinfo)
            assert repr.reprtraceback
            assert len(repr.reprtraceback.reprentries) == len(reprtb.reprentries)
            assert repr.reprcrash.path.endswith("mod.py")
            assert repr.reprcrash.message == "ValueError: 0"
开发者ID:Eleanor66613,项目名称:CS249-midterm,代码行数:22,代码来源:test_excinfo.py


注:本文中的py._code.code.FormattedExcinfo.repr_traceback方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。