-
-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathtest_main.py
39 lines (29 loc) · 891 Bytes
/
test_main.py
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
31
32
33
34
35
36
37
38
39
# -*- coding: utf-8 -*-
import os.path as osp
import re
import subprocess
import sys
import pytest
def get_testdir():
filename = osp.normcase(osp.dirname(osp.abspath(__file__)))
return osp.realpath(filename)
@pytest.mark.skipif(
sys.platform in ("emscripten",),
reason="Pyodide does not support processes",
)
def test_cli():
script_file = osp.join(get_testdir(), "data", "script.m")
# asserts output contains 'Hello' and '2'
result = subprocess.run(
["mathics", "-e", "Print[1+1];", "-script", script_file],
capture_output=True,
)
assert re.match(r"Hello\s+2", result.stdout.decode("utf-8"))
assert result.returncode == 0
result = subprocess.run(
["mathics", "--execute", "2+3", "---trace-builtins"],
capture_output=False,
)
assert result.returncode == 0
if __name__ == "__main__":
test_cli()