Debian Codegraph @

test/units/_internal/test_event_formatting.py

raw
1 from __future__ import annotations
2
3 import traceback
4
5 from ansible._internal._errors import _error_factory
6 from ansible._internal._event_formatting import format_event_traceback
7 from units.mock.error_helper import raise_exceptions
8
9 import pytest
10
11
12 def test_traceback_formatting() -> None:
13 """Verify our traceback formatting mimics the Python traceback formatting."""
14 with pytest.raises(Exception) as error:
15 raise_exceptions((
16 Exception('a'),
17 Exception('b'),
18 Exception('c'),
19 Exception('d'),
20 ))
21
22 event = _error_factory.ControllerEventFactory.from_exception(error.value, True)
23 ansible_tb = format_event_traceback(event)
24 python_tb = ''.join(traceback.format_exception(error.value))
25
26 assert ansible_tb == python_tb