Debian Codegraph @

tests/unit/test_formatter.py

raw symbols SCIP
1 """Tests of custom formatter.
2 """
3
4 # test_example.py
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 # The following does not work on Github when running with windows.
37 # import os
38 # IN_GITHUB_ACTIONS = bool(os.getenv("GITHUB_ACTIONS"))
39 # @pytest.mark.skipif(IN_GITHUB_ACTIONS, reason="Test doesn't work reliably in Github Actions.")
40 #
41 # I am thus the only one to run this test.
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