mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
more mocks for test_xonfig_kernel
This commit is contained in:
parent
0fc9098aad
commit
48238beec1
2 changed files with 14 additions and 1 deletions
|
@ -1,2 +1,6 @@
|
|||
class KernelSpecManager:
|
||||
pass
|
||||
|
||||
|
||||
class NoSuchKernel(Exception):
|
||||
pass
|
||||
|
|
|
@ -79,6 +79,8 @@ def test_xonfig_kernel_with_jupyter(monkeypatch, capsys, fake_lib, xonsh_builtin
|
|||
cap_args = None
|
||||
cap_spec = None
|
||||
|
||||
import jupyter_client.kernelspec # from fake_lib, hopefully.
|
||||
|
||||
def mock_install_kernel_spec(*args, **kwargs): # arg[0] is self
|
||||
nonlocal cap_args
|
||||
nonlocal cap_spec
|
||||
|
@ -86,7 +88,8 @@ def test_xonfig_kernel_with_jupyter(monkeypatch, capsys, fake_lib, xonsh_builtin
|
|||
spec_file = os.path.join(args[1], "kernel.json")
|
||||
cap_spec = json.load(open(spec_file, "r"))
|
||||
|
||||
import jupyter_client.kernelspec # from fake_lib, hopefully.
|
||||
def mock_get_kernel_spec(*args, **kwargs):
|
||||
raise jupyter_client.kernelspec.NoSuchKernel
|
||||
|
||||
monkeypatch.setattr(
|
||||
jupyter_client.kernelspec.KernelSpecManager,
|
||||
|
@ -94,6 +97,12 @@ def test_xonfig_kernel_with_jupyter(monkeypatch, capsys, fake_lib, xonsh_builtin
|
|||
value=mock_install_kernel_spec,
|
||||
raising=False,
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
jupyter_client.kernelspec.KernelSpecManager,
|
||||
"get_kernel_spec",
|
||||
value=mock_get_kernel_spec,
|
||||
raising=False,
|
||||
)
|
||||
|
||||
rc = xonfig_main(["jupyter-kernel"])
|
||||
assert rc == 0
|
||||
|
|
Loading…
Add table
Reference in a new issue