Skip to content

Commit e942d85

Browse files
fix: Use non-gui matplotlib backend for tests to avoid hanging on ipywidgets interact (#2098)
* Avoid the notebook tests hanging on the ipywidgets interact sections of `InterpolationCodes.ipynb` by setting the matplotlib backend to the non-gui Agg which disallows the creation of the gui elements that are causing the problem. * Remove '%pylab inline' from InterpolationCodes.ipynb as pylab is very deprecated. * Add --verobse flag to notebook tests to make it easier to track the progress of the notebooks in the CI logs.
1 parent 14127ae commit e942d85

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

.github/workflows/notebooks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ jobs:
3939
# Override the ini option for filterwarnings with an empty list to disable error
4040
# on filterwarnings as testing for notebooks to run with the latest API, not if
4141
# Jupyter infrastructure is warning free.
42-
pytest --override-ini filterwarnings= tests/test_notebooks.py
42+
pytest --verbose --override-ini filterwarnings= tests/test_notebooks.py

docs/examples/notebooks/learn/InterpolationCodes.ipynb

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,11 @@
44
"cell_type": "code",
55
"execution_count": 1,
66
"metadata": {},
7-
"outputs": [
8-
{
9-
"name": "stdout",
10-
"output_type": "stream",
11-
"text": [
12-
"Populating the interactive namespace from numpy and matplotlib\n"
13-
]
14-
}
15-
],
7+
"outputs": [],
168
"source": [
17-
"%pylab inline\n",
18-
"from ipywidgets import interact\n",
199
"import matplotlib.pyplot as plt\n",
10+
"import numpy as np\n",
11+
"from ipywidgets import interact\n",
2012
"from mpl_toolkits.mplot3d import Axes3D"
2113
]
2214
},

tests/test_notebooks.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
import os
12
import sys
23
from pathlib import Path
34

45
import papermill as pm
56
import pytest
67
import scrapbook as sb
78

9+
# Avoid hanging on with ipywidgets interact by using non-gui backend
10+
os.environ["MPLBACKEND"] = "agg"
11+
812

913
@pytest.fixture()
1014
def common_kwargs(tmpdir):

0 commit comments

Comments
 (0)