Skip to content

Commit 115cfd0

Browse files
committed
Readd test that sage.all imports without error in new session
1 parent efac68c commit 115cfd0

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/sage/all_test.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import os
2+
import subprocess
3+
import sys
4+
5+
6+
def test_import_sage_all_in_fresh_interpreter():
7+
# Prepare a clean-ish environment, without any sage variables
8+
env = os.environ.copy()
9+
env.pop("PYTHONSTARTUP", None)
10+
for var in list(env):
11+
if var.startswith("SAGE_"):
12+
env.pop(var, None)
13+
14+
proc = subprocess.run(
15+
[sys.executable, "-c", "import sage.all"],
16+
stdout=subprocess.PIPE,
17+
stderr=subprocess.PIPE,
18+
env=env,
19+
text=True, check=False,
20+
)
21+
assert proc.returncode == 0, (
22+
"Importing 'sage.all' in a fresh interpreter failed.\n"
23+
f"Return code: {proc.returncode}\n"
24+
f"Stdout:\n{proc.stdout}\n"
25+
f"Stderr:\n{proc.stderr}"
26+
)
27+
assert proc.stderr == ""
28+
assert proc.stdout == ""

src/sage/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ py.install_sources(
8383
'__init__.py',
8484
'all.py',
8585
'all_cmdline.py',
86+
'all_test.py',
8687
'env.py',
8788
'version.py',
8889
subdir: 'sage',

0 commit comments

Comments
 (0)