| 1 |
"""Tests of custom formatter. |
| 2 |
""" |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
import os |
| 7 |
import subprocess |
| 8 |
import sys |
| 9 |
|
| 10 |
import pytest |
| 11 |
|
| 12 |
def run(lang): |
| 13 |
proc = subprocess.run( |
| 14 |
[ |
| 15 |
sys.executable, |
| 16 |
"-m", |
| 17 |
"friendly_traceback", |
| 18 |
"--formatter", |
| 19 |
"tests.fake_formatter.get_cause", |
| 20 |
"tests/name_error.py", |
| 21 |
"--lang", |
| 22 |
lang, |
| 23 |
], |
| 24 |
stdout=subprocess.PIPE, |
| 25 |
stderr=subprocess.PIPE, |
| 26 |
universal_newlines=True, |
| 27 |
check=False, |
| 28 |
) |
| 29 |
return proc.stderr |
| 30 |
|
| 31 |
|
| 32 |
def test_formatter_en(): |
| 33 |
result = run('en') |
| 34 |
assert "The similar name `pi` was found in the local scope." in result |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
@pytest.mark.skipif("Andre" not in __file__, reason="Test does not work reliably in Github Actions.") |
| 44 |
def test_formatter_fr(): |
| 45 |
result = run('fr') |
| 46 |
assert "Le nom semblable `pi` a été trouvé dans la portée locale." in result |