forked from sagemath/sage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest_test.py
57 lines (48 loc) · 1.45 KB
/
conftest_test.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from pathlib import Path
import subprocess
from sage.env import SAGE_SRC
input_file = Path(SAGE_SRC) / "conftest_inputtest.py"
class TestOldDoctestSageScript:
"""Run `sage --t`."""
def test_invoke_on_inputtest_file(self):
result = subprocess.run(
["sage", "-t", input_file],
capture_output=True,
text=True,
)
assert result.returncode == 1 # There are failures in the input test
assert (
"Failed example:\n"
" something()\n"
"Expected:\n"
" 44\n"
"Got:\n"
" 42\n"
"" in result.stdout
)
class TestPytestSageScript:
"""Run `sage --pytest`."""
def test_invoke_on_inputtest_file(self):
result = subprocess.run(
["sage", "--pytest", input_file],
capture_output=True,
text=True,
)
assert result.returncode == 1 # There are failures in the input test
assert (
"004 EXAMPLES::\n"
"005 \n"
"006 sage: something()\n"
"007 42\n"
"008 sage: something() + 1\n"
"009 43\n"
"010 \n"
"011 TESTS::\n"
"012 \n"
"013 sage: something()\n"
"Expected:\n"
" 44\n"
"Got:\n"
" 42\n"
"" in result.stdout
)