本文整理汇总了Python中sentry.interfaces.exception.Exception类的典型用法代码示例。如果您正苦于以下问题:Python Exception类的具体用法?Python Exception怎么用?Python Exception使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Exception类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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']
开发者ID:duanshuaimin,项目名称:sentry,代码行数:26,代码来源:test_exception.py
示例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
开发者ID:pauloschilling,项目名称:sentry,代码行数:28,代码来源:test_exception.py
示例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
开发者ID:duanshuaimin,项目名称:sentry,代码行数:33,代码来源:test_exception.py
示例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>'
开发者ID:duanshuaimin,项目名称:sentry,代码行数:25,代码来源:test_exception.py
示例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'
开发者ID:alshopov,项目名称:sentry,代码行数:29,代码来源:test_exception.py
示例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"}'
开发者ID:alshopov,项目名称:sentry,代码行数:7,代码来源:test_exception.py
示例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,
}]
},
}
]
)
)
开发者ID:alshopov,项目名称:sentry,代码行数:30,代码来源:test_exception.py
示例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')
开发者ID:Superdense,项目名称:sentry,代码行数:7,代码来源:test_stacktrace.py
示例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
开发者ID:duanshuaimin,项目名称:sentry,代码行数:8,代码来源:test_exception.py
示例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'
开发者ID:yaoqi,项目名称:sentry,代码行数:9,代码来源:test_exception.py
示例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'
开发者ID:duanshuaimin,项目名称:sentry,代码行数:10,代码来源:test_exception.py
示例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'
开发者ID:duanshuaimin,项目名称:sentry,代码行数:10,代码来源:test_exception.py
示例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')
开发者ID:Superdense,项目名称:sentry,代码行数:12,代码来源:test_stacktrace.py
示例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())
开发者ID:yaoqi,项目名称:sentry,代码行数:15,代码来源:test_exception.py
示例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}]},
},
]
)
)
开发者ID:Getsidecar,项目名称:sentry,代码行数:19,代码来源:test_exception.py
示例16: test_slim_exception_data_over_max
def test_slim_exception_data_over_max(insta_snapshot):
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)
insta_snapshot(interface.to_json())
开发者ID:yaoqi,项目名称:sentry,代码行数:22,代码来源:test_exception.py
示例17: test_context_with_only_system_frames
def test_context_with_only_system_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": False}]},
},
{
"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 not context["hasSystemFrames"]
开发者ID:AyrtonRicardo,项目名称:sentry,代码行数:23,代码来源:test_exception.py
示例18: test_over_max
def test_over_max(self):
values = []
for x in xrange(5):
exc = {"value": "exc %d" % x, "stacktrace": {"frames": []}}
values.append(exc)
for y in xrange(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)
print (frame.filename)
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:pombredanne,项目名称:django-sentry,代码行数:36,代码来源:test_exception.py
示例19: 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"
开发者ID:Getsidecar,项目名称:sentry,代码行数:6,代码来源:test_exception.py
示例20: 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
开发者ID:pombredanne,项目名称:django-sentry,代码行数:4,代码来源:test_exception.py
注:本文中的sentry.interfaces.exception.Exception类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论