File: test_throwable.py

package info (click to toggle)
python-aws-xray-sdk 0.95-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 792 kB
  • sloc: python: 3,006; makefile: 20
file content (30 lines) | stat: -rw-r--r-- 852 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from aws_xray_sdk.core.models.throwable import Throwable


def test_message_and_type():

    e = TypeError('msg')
    throwable = Throwable(e, None, True)
    assert throwable.message == 'msg'
    assert throwable.type == type(e).__name__
    assert throwable.remote


def test_stack_trace_parsing():
    # sample output using `traceback.extract_stack()`
    stack = [
        ('/path/to/test.py', 10, 'module', 'another_function()'),
        ('/path/to/test.py', 3, 'another_function', 'wrong syntax'),
    ]

    throwable = Throwable(TypeError(), stack)

    entry1 = throwable.stack[0]
    assert entry1['path'] == 'test.py'
    assert entry1['line'] == 10
    assert entry1['label'] == 'module'

    entry2 = throwable.stack[1]
    assert entry2['path'] == 'test.py'
    assert entry2['line'] == 3
    assert entry2['label'] == 'another_function'