Skip to content

Commit ab5ffa6

Browse files
authored
Merge pull request #366 from bollwyvl/gh-362-explicit-jp-server-2-robot
Fix tests against jupyter_server 2
2 parents 15447ba + 9484cc7 commit ab5ffa6

File tree

5 files changed

+41
-7
lines changed

5 files changed

+41
-7
lines changed

.github/workflows/test.yaml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979
if: always()
8080
uses: actions/upload-artifact@v3
8181
with:
82-
name: unit-tests-${{matrix.python }}-${{ matrix.jupyter-app }}-${{matrix.jupyterlab-version}}-${{ github.run_number }}
82+
name: unit-tests-${{ matrix.python-version }}-${{ matrix.jupyter-app }}-${{ matrix.jupyterlab-version }}-${{ github.run_number }}
8383
path: |
8484
./build/pytest
8585
./build/coverage
@@ -103,6 +103,12 @@ jobs:
103103
jupyter lab build --minimize=False --debug
104104
105105
- name: Check the lab extension
106+
# We test the labextension thoroughly in the acceptance tests below, so
107+
# we have conditionally disabled this basic check is to avoid issues in
108+
# jupyterlab.browser_check with jupyterlab 2 and a modern version of
109+
# python (3.11+).
110+
#
111+
if: ${{ !(matrix.jupyterlab-version == '2' && startsWith(matrix.python-version, '3.1')) }}
106112
run: |
107113
jupyter labextension list
108114
jupyter labextension list 2>&1 | grep -ie '@jupyterlab/server-proxy.*OK.*'
@@ -111,7 +117,7 @@ jobs:
111117
- name: Install Acceptance test dependencies
112118
run: |
113119
# the acceptance test requires notebook to run
114-
pip install "notebook<7" robotframework-jupyterlibrary
120+
pip install "notebook<7" "robotframework-jupyterlibrary>=0.4.2"
115121
116122
- name: Run acceptance tests
117123
run: |
@@ -121,6 +127,6 @@ jobs:
121127
if: always()
122128
uses: actions/upload-artifact@v3
123129
with:
124-
name: acceptance-tests-${{ matrix.python }}-${{ matrix.jupyter-app }}-${{ matrix.jupyterlab-version }}-${{ github.run_number }}
130+
name: acceptance-tests-${{ matrix.python-version }}-${{ matrix.jupyter-app }}-${{ matrix.jupyterlab-version }}-${{ github.run_number }}
125131
path: |
126132
./build/robot

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
"pytest-html"
9898
],
9999
"acceptance": [
100-
"robotframework-jupyterlibrary"
100+
"robotframework-jupyterlibrary>=0.4.2"
101101
]
102102
},
103103
zip_safe=False,

tests/acceptance/__init__.robot

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ Suite Teardown Clean Up
1313
Set Up
1414
${notebook dir} = Set Variable ${OUTPUT DIR}${/}notebooks
1515
Copy Directory resources ${notebook dir}
16+
Set Screenshot Directory EMBED
1617
Set Environment Variable
1718
... name=JUPYTER_CONFIG_DIR
1819
... value=${notebook dir}
1920
Wait For New Jupyter Server To Be Ready
21+
... %{JUPYTER_LIBRARY_APP_COMMAND}
2022
... stdout=${OUTPUT DIR}${/}server.log
2123
... notebook_dir=${notebook dir}
2224
... cwd=${notebook dir}

tests/acceptance/test_acceptance.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,48 @@
1-
import subprocess
2-
import pytest
31
from pathlib import Path
2+
import os
43
import shutil
4+
import subprocess
5+
6+
import pytest
57

68
HERE = Path(__file__).parent
79
OUTPUT = HERE.parent.parent / "build/robot"
10+
JUPYTER_SERVER_INFO = None
11+
12+
try:
13+
import jupyter_server
14+
JUPYTER_SERVER_INFO = jupyter_server.version_info
15+
except ImportError:
16+
pass
817

918

1019
def test_robot():
1120
"""run acceptance tests with robotframework"""
1221
with_robot = pytest.importorskip("JupyterLibrary")
1322

23+
env = dict(**os.environ)
24+
25+
# JUPYTER_LIBRARY_* env vars documentation:
26+
# https://robotframework-jupyterlibrary.readthedocs.io/en/stable/LIMITS.html#notebookapp-vs-serverapp
27+
if JUPYTER_SERVER_INFO is None:
28+
env.update(
29+
JUPYTER_LIBRARY_APP_COMMAND="jupyter-notebook",
30+
JUPYTER_LIBRARY_APP="NotebookApp",
31+
)
32+
else:
33+
env.update(
34+
JUPYTER_LIBRARY_APP_COMMAND="jupyter-server",
35+
JUPYTER_LIBRARY_APP="ServerApp",
36+
)
37+
38+
1439
if OUTPUT.exists():
1540
shutil.rmtree(OUTPUT)
1641

1742
return_code = subprocess.call(
1843
["robot", "--consolecolors=on", f"--outputdir={OUTPUT}", str(HERE)],
19-
cwd=str(HERE)
44+
cwd=str(HERE),
45+
env=env
2046
)
2147

2248
assert return_code == 0

0 commit comments

Comments
 (0)