File: catch_for_formatting_tests.py

package info (click to toggle)
python-friendly-traceback 0.7.62%2Bgit20240811.d7dbff6-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,264 kB
  • sloc: python: 21,500; makefile: 4
file content (22 lines) | stat: -rw-r--r-- 636 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import pytest

import friendly_traceback
from friendly_traceback.console_helpers import _get_info
from ..syntax_errors_formatting_cases import descriptions

friendly_traceback.set_lang("en")

where = "parsing_error_source"
cause = "cause"

@pytest.mark.parametrize("filename", descriptions.keys())
def test_syntax_errors(filename):
    expected = descriptions[filename]
    try:
        exec("from . import %s" % filename)
    except SyntaxError:
        friendly_traceback.explain_traceback(redirect="capture")
    info = _get_info()

    assert expected[where] == info[where]  # noqa
    assert expected[cause] in info[cause]  # noqa