Skip to content

Commit 8f21e32

Browse files
committed
Hide spurious stderr output in notebook_cmd_test.py
1 parent 4cdd703 commit 8f21e32

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/sage/cli/notebook_cmd_test.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,14 @@ def test_jupyterlab_explicitly():
2929
def test_invalid_notebook_choice():
3030
parser = argparse.ArgumentParser()
3131
JupyterNotebookCmd.extend_parser(parser)
32-
with pytest.raises(SystemExit):
33-
parser.parse_args(["--notebook", "invalid"])
32+
with io.StringIO() as f:
33+
old_sys_stderr = sys.stderr
34+
try:
35+
sys.stderr = f
36+
with pytest.raises(SystemExit):
37+
parser.parse_args(["--notebook", "invalid"])
38+
finally:
39+
sys.stderr = old_sys_stderr
3440

3541

3642
def test_help():

0 commit comments

Comments
 (0)