Debian Codegraph @

tests/test_runapp.py

raw
1 import sys
2 from subprocess import run
3
4
5 def test_runapp(tmp_path):
6 test_py = tmp_path / "test.py"
7 with test_py.open("w") as f:
8 f.write("print('hello')")
9
10 p = run(
11 [sys.executable, "-m", "jupyter_client.runapp", str(test_py)],
12 capture_output=True,
13 text=True,
14 check=True,
15 )
16 assert p.stdout.strip() == "hello"
17
18
19 def test_no_such_kernel(tmp_path):
20 test_py = tmp_path / "test.py"
21 with test_py.open("w") as f:
22 f.write("print('hello')")
23 kernel_name = "nosuchkernel"
24 p = run(
25 [sys.executable, "-m", "jupyter_client.runapp", "--kernel", kernel_name, str(test_py)],
26 capture_output=True,
27 text=True,
28 check=False,
29 )
30 assert p.returncode
31 assert "Could not find kernel" in p.stderr
32 assert kernel_name in p.stderr
33 # shouldn't show a traceback
34 assert "Traceback" not in p.stderr