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


Python Exception.to_python方法代码示例

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


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

示例1: test_context_with_mixed_frames

# 需要导入模块: from sentry.interfaces.exception import Exception [as 别名]
# 或者: from sentry.interfaces.exception.Exception import to_python [as 别名]
    def test_context_with_mixed_frames(self):
        inst = Exception.to_python(dict(values=[{
            'type': 'ValueError',
            'value': 'hello world',
            'module': 'foo.bar',
            'stacktrace': {'frames': [{
                'filename': 'foo/baz.py',
                'lineno': 1,
                'in_app': True,
            }]},
        }, {
            'type': 'ValueError',
            'value': 'hello world',
            'module': 'foo.bar',
            'stacktrace': {'frames': [{
                'filename': 'foo/baz.py',
                'lineno': 1,
                'in_app': False,
            }]},
        }]))

        self.create_event(data={
            'sentry.interfaces.Exception': inst.to_json(),
        })
        context = inst.get_api_context()
        assert context['hasSystemFrames']
开发者ID:duanshuaimin,项目名称:sentry,代码行数:28,代码来源:test_exception.py

示例2: test_context_with_only_app_frames

# 需要导入模块: from sentry.interfaces.exception import Exception [as 别名]
# 或者: from sentry.interfaces.exception.Exception import to_python [as 别名]
    def test_context_with_only_app_frames(self):
        inst = Exception.to_python(dict(values=[{
            'type': 'ValueError',
            'value': 'hello world',
            'module': 'foo.bar',
            'stacktrace': {'frames': [{
                'filename': 'foo/baz.py',
                'lineno': 1,
                'in_app': True,
            }]},
        }, {
            'type': 'ValueError',
            'value': 'hello world',
            'module': 'foo.bar',
            'stacktrace': {'frames': [{
                'filename': 'foo/baz.py',
                'lineno': 1,
                'in_app': True,
            }]},
        }]))

        event = self.create_event(data={
            'sentry.interfaces.Exception': inst.to_json(),
        })
        context = inst.get_context(event)
        assert context['system_frames'] == 0
        assert context['exceptions'][0]['stacktrace']['system_frames'] == 0
        assert context['exceptions'][1]['stacktrace']['system_frames'] == 0
开发者ID:pauloschilling,项目名称:sentry,代码行数:30,代码来源:test_exception.py

示例3: test_over_max

# 需要导入模块: from sentry.interfaces.exception import Exception [as 别名]
# 或者: from sentry.interfaces.exception.Exception import to_python [as 别名]
    def test_over_max(self):
        values = []
        for x in range(5):
            exc = {'value': 'exc %d' % x, 'stacktrace': {'frames': []}}
            values.append(exc)
            for y in range(5):
                exc['stacktrace']['frames'].append({
                    'filename': 'exc %d frame %d' % (x, y),
                    'vars': {'foo': 'bar'},
                    'context_line': 'b',
                    'pre_context': ['a'],
                    'post_context': ['c'],
                })

        interface = Exception.to_python({'values': values})

        # slim to 10 frames to make tests easier
        slim_exception_data(interface, 10)

        assert len(interface.values) == 5
        for e_num, value in enumerate(interface.values):
            assert value.value == 'exc %d' % e_num
            assert len(value.stacktrace.frames) == 5
            for f_num, frame in enumerate(value.stacktrace.frames):
                assert frame.filename == 'exc %d frame %d' % (e_num, f_num)
                if e_num in (0, 4):
                    assert frame.vars is not None
                    assert frame.pre_context is not None
                    assert frame.post_context is not None
                else:
                    assert frame.vars is None
                    assert frame.pre_context is None
                    assert frame.post_context is None
开发者ID:duanshuaimin,项目名称:sentry,代码行数:35,代码来源:test_exception.py

示例4: test_context_with_raw_stacks

# 需要导入模块: from sentry.interfaces.exception import Exception [as 别名]
# 或者: from sentry.interfaces.exception.Exception import to_python [as 别名]
    def test_context_with_raw_stacks(self):
        inst = Exception.to_python(dict(values=[{
            'type': 'ValueError',
            'value': 'hello world',
            'module': 'foobar',
            'raw_stacktrace': {'frames': [{
                'filename': None,
                'lineno': 1,
                'function': '<redacted>',
                'in_app': True,
            }]},
            'stacktrace': {'frames': [{
                'filename': 'foo/baz.c',
                'lineno': 1,
                'function': 'main',
                'in_app': True,
            }]},
        }]))

        self.create_event(data={
            'sentry.interfaces.Exception': inst.to_json(),
        })
        context = inst.get_api_context()
        assert context['values'][0]['stacktrace']['frames'][0]['function'] == 'main'
        assert context['values'][0]['rawStacktrace']['frames'][0]['function'] == '<redacted>'
开发者ID:duanshuaimin,项目名称:sentry,代码行数:27,代码来源:test_exception.py

示例5: test_context_with_symbols

# 需要导入模块: from sentry.interfaces.exception import Exception [as 别名]
# 或者: from sentry.interfaces.exception.Exception import to_python [as 别名]
    def test_context_with_symbols(self):
        inst = Exception.to_python(
            dict(
                values=[
                    {
                        'type': 'ValueError',
                        'value': 'hello world',
                        'module': 'foo.bar',
                        'stacktrace': {
                            'frames': [
                                {
                                    'filename': 'foo/baz.py',
                                    'function': 'myfunc',
                                    'symbol': 'Class.myfunc',
                                    'lineno': 1,
                                    'in_app': True,
                                }
                            ]
                        },
                    }
                ]
            )
        )

        self.create_event(data={
            'sentry.interfaces.Exception': inst.to_json(),
        })
        context = inst.get_api_context()
        assert context['values'][0]['stacktrace']['frames'][0]['symbol'] == 'Class.myfunc'
开发者ID:alshopov,项目名称:sentry,代码行数:31,代码来源:test_exception.py

示例6: test_non_string_value_with_no_type

# 需要导入模块: from sentry.interfaces.exception import Exception [as 别名]
# 或者: from sentry.interfaces.exception.Exception import to_python [as 别名]
 def test_non_string_value_with_no_type(self):
     inst = Exception.to_python(
         {
             'value': {'foo': 'bar'},
         }
     )
     assert inst.values[0].value == '{"foo":"bar"}'
开发者ID:alshopov,项目名称:sentry,代码行数:9,代码来源:test_exception.py

示例7: interface

# 需要导入模块: from sentry.interfaces.exception import Exception [as 别名]
# 或者: from sentry.interfaces.exception.Exception import to_python [as 别名]
 def interface(self):
     return Exception.to_python(
         dict(
             values=[
                 {
                     'type': 'ValueError',
                     'value': 'hello world',
                     'module': 'foo.bar',
                     'stacktrace': {
                         'frames': [{
                             'filename': 'foo/baz.py',
                             'lineno': 1,
                             'in_app': True,
                         }]
                     },
                 }, {
                     'type': 'ValueError',
                     'value': 'hello world',
                     'module': 'foo.bar',
                     'stacktrace': {
                         'frames': [{
                             'filename': 'foo/baz.py',
                             'lineno': 1,
                             'in_app': True,
                         }]
                     },
                 }
             ]
         )
     )
开发者ID:alshopov,项目名称:sentry,代码行数:32,代码来源:test_exception.py

示例8: test_get_composite_hash_uses_exception_value_if_no_type_or_stack

# 需要导入模块: from sentry.interfaces.exception import Exception [as 别名]
# 或者: from sentry.interfaces.exception.Exception import to_python [as 别名]
 def test_get_composite_hash_uses_exception_value_if_no_type_or_stack(self):
     interface = Stacktrace(frames=[])
     interface_exc = Exception.to_python(dict(value='bar'))
     result = interface.get_composite_hash({
         'sentry.interfaces.Exception': interface_exc,
     })
     self.assertEquals(result[-1], 'bar')
开发者ID:Superdense,项目名称:sentry,代码行数:9,代码来源:test_stacktrace.py

示例9: test_under_max

# 需要导入模块: from sentry.interfaces.exception import Exception [as 别名]
# 或者: from sentry.interfaces.exception.Exception import to_python [as 别名]
 def test_under_max(self):
     interface = Exception.to_python({'values': [
         {'value': 'foo',
          'stacktrace': {'frames': [{'filename': 'foo'}]},
         }
     ]})
     slim_exception_data(interface)
     assert len(interface.values[0].stacktrace.frames) == 1
开发者ID:duanshuaimin,项目名称:sentry,代码行数:10,代码来源:test_exception.py

示例10: test_iteration

# 需要导入模块: from sentry.interfaces.exception import Exception [as 别名]
# 或者: from sentry.interfaces.exception.Exception import to_python [as 别名]
def test_iteration():
    inst = Exception.to_python({
        'values': [None, {'type': 'ValueError'}, None]
    })

    assert len(inst) == 1
    assert inst[0].type == 'ValueError'
    for exc in inst:
        assert exc.type == 'ValueError'
开发者ID:yaoqi,项目名称:sentry,代码行数:11,代码来源:test_exception.py

示例11: test_args_as_keyword_args

# 需要导入模块: from sentry.interfaces.exception import Exception [as 别名]
# 或者: from sentry.interfaces.exception.Exception import to_python [as 别名]
 def test_args_as_keyword_args(self):
     inst = Exception.to_python(dict(values=[{
         'type': 'ValueError',
         'value': 'hello world',
         'module': 'foo.bar',
     }]))
     assert type(inst.values[0]) is SingleException
     assert inst.values[0].type == 'ValueError'
     assert inst.values[0].value == 'hello world'
     assert inst.values[0].module == 'foo.bar'
开发者ID:duanshuaimin,项目名称:sentry,代码行数:12,代码来源:test_exception.py

示例12: test_args_as_old_style

# 需要导入模块: from sentry.interfaces.exception import Exception [as 别名]
# 或者: from sentry.interfaces.exception.Exception import to_python [as 别名]
 def test_args_as_old_style(self):
     inst = Exception.to_python({
         'type': 'ValueError',
         'value': 'hello world',
         'module': 'foo.bar',
     })
     assert type(inst.values[0]) is SingleException
     assert inst.values[0].type == 'ValueError'
     assert inst.values[0].value == 'hello world'
     assert inst.values[0].module == 'foo.bar'
开发者ID:duanshuaimin,项目名称:sentry,代码行数:12,代码来源:test_exception.py

示例13: test_get_composite_hash_uses_exception_if_present

# 需要导入模块: from sentry.interfaces.exception import Exception [as 别名]
# 或者: from sentry.interfaces.exception.Exception import to_python [as 别名]
 def test_get_composite_hash_uses_exception_if_present(self):
     interface = Stacktrace.to_python(dict(frames=[{
         'context_line': 'foo bar',
         'lineno': 1,
         'filename': 'foo.py',
         'function': 'bar'
     }]))
     interface_exc = Exception.to_python(dict(type='exception', value='bar'))
     result = interface.get_composite_hash({
         'sentry.interfaces.Exception': interface_exc,
     })
     self.assertEquals(result[-1], 'exception')
开发者ID:Superdense,项目名称:sentry,代码行数:14,代码来源:test_stacktrace.py

示例14: test_slim_exception_data_under_max

# 需要导入模块: from sentry.interfaces.exception import Exception [as 别名]
# 或者: from sentry.interfaces.exception.Exception import to_python [as 别名]
def test_slim_exception_data_under_max(insta_snapshot):
    interface = Exception.to_python(
        {
            'values': [{
                'value': 'foo',
                'stacktrace': {
                    'frames': [{
                        'filename': 'foo'
                    }]
                },
            }]
        }
    )
    slim_exception_data(interface)
    insta_snapshot(interface.to_json())
开发者ID:yaoqi,项目名称:sentry,代码行数:17,代码来源:test_exception.py

示例15: interface

# 需要导入模块: from sentry.interfaces.exception import Exception [as 别名]
# 或者: from sentry.interfaces.exception.Exception import to_python [as 别名]
 def interface(self):
     return Exception.to_python(
         dict(
             values=[
                 {
                     "type": "ValueError",
                     "value": "hello world",
                     "module": "foo.bar",
                     "stacktrace": {"frames": [{"filename": "foo/baz.py", "lineno": 1, "in_app": True}]},
                 },
                 {
                     "type": "ValueError",
                     "value": "hello world",
                     "module": "foo.bar",
                     "stacktrace": {"frames": [{"filename": "foo/baz.py", "lineno": 1, "in_app": True}]},
                 },
             ]
         )
     )
开发者ID:Getsidecar,项目名称:sentry,代码行数:21,代码来源:test_exception.py


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