Skip to content

Commit a85f9b8

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

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/sage/cli/notebook_cmd_test.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import io
2+
import sys
13
import argparse
24

35
import pytest
@@ -29,8 +31,14 @@ def test_jupyterlab_explicitly():
2931
def test_invalid_notebook_choice():
3032
parser = argparse.ArgumentParser()
3133
JupyterNotebookCmd.extend_parser(parser)
32-
with pytest.raises(SystemExit):
33-
parser.parse_args(["--notebook", "invalid"])
34+
with io.StringIO() as f:
35+
old_sys_stderr = sys.stderr
36+
try:
37+
sys.stderr = f
38+
with pytest.raises(SystemExit):
39+
parser.parse_args(["--notebook", "invalid"])
40+
finally:
41+
sys.stderr = old_sys_stderr
3442

3543

3644
def test_help():

0 commit comments

Comments
 (0)