本文整理汇总了Python中sentry.interfaces.exception.Exception类的典型用法代码示例。如果您正苦于以下问题:Python Exception类的具体用法?Python Exception怎么用?Python Exception使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Exception类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_context_with_mixed_frames
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']
示例2: test_context_with_only_app_frames
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
示例3: test_over_max
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
示例4: test_context_with_raw_stacks
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>'
示例5: test_context_with_symbols
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'
示例6: test_non_string_value_with_no_type
def test_non_string_value_with_no_type(self):
inst = Exception.to_python(
{
'value': {'foo': 'bar'},
}
)
assert inst.values[0].value == '{"foo":"bar"}'
示例7: interface
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,
}]
},
}
]
)
)
示例8: test_get_composite_hash_uses_exception_value_if_no_type_or_stack
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')
示例9: test_under_max
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
示例10: test_iteration
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'
示例11: test_args_as_keyword_args
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'
示例12: test_args_as_old_style
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'
示例13: test_get_composite_hash_uses_exception_if_present
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')
示例14: test_slim_exception_data_under_max
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())
示例15: interface
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}]},
},
]
)
)