From 416873f90ee19fc1520dd61636357dc605ad6c48 Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Tue, 27 Aug 2019 16:24:09 +0200 Subject: [PATCH] Install xeus-python kernelspec for tests --- README.md | 2 -- azure-pipelines.yml | 1 - tests/run-test.py | 28 +++++++++++++++++++++++++++- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2b09400e..a04842a2 100644 --- a/README.md +++ b/README.md @@ -39,8 +39,6 @@ XEUS_LOG=1 jupyter lab --no-browser --watch ### Tests -Make sure `xeus-python` is installed and `jupyter --paths` points to where the kernel is installed. - To run the tests: ```bash diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0f02c626..d923d064 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -28,7 +28,6 @@ steps: - bash: | source activate jupyterlab-debugger - export JUPYTER_PATH=${CONDA_PREFIX}/share/jupyter export XEUS_LOG=1 jlpm run test displayName: Run the tests diff --git a/tests/run-test.py b/tests/run-test.py index ba158164..6458da47 100644 --- a/tests/run-test.py +++ b/tests/run-test.py @@ -1,10 +1,36 @@ # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. +import json import os -from jupyterlab.tests.test_app import run_jest +from os.path import join as pjoin + +from jupyter_core import paths +from jupyterlab.tests.test_app import run_jest, JestApp HERE = os.path.realpath(os.path.dirname(__file__)) + +def _install_xpython_kernel(): + # Mimics: https://github.com/jupyterlab/jupyterlab/blob/cd2fb6ac3ecfae2bb4bcab84797932e625e9bb2f/jupyterlab/tests/test_app.py#L80-L95 + kernel_json = { + 'argv': [ + 'xpython', + '-f', '{connection_file}' + ], + 'display_name': "xpython", + 'language': 'python' + } + kernel_dir = pjoin(paths.jupyter_data_dir(), 'kernels', 'xpython') + os.makedirs(kernel_dir) + with open(pjoin(kernel_dir, 'kernel.json'), 'w') as f: + f.write(json.dumps(kernel_json)) + + if __name__ == '__main__': + jest_app = JestApp.instance() + + # install the kernel spec for xeus-python + _install_xpython_kernel() + run_jest(HERE)