Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix use of deprecated API and update test matrix #1696

Merged
merged 17 commits into from Dec 28, 2021
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9' ]
python-version: [ '3.7', '3.9', '3.10' ]
steps:
- name: Check out repository code
uses: actions/checkout@v2
Expand Down
54 changes: 31 additions & 23 deletions .github/workflows/tests.yml
Expand Up @@ -8,40 +8,35 @@ on:

jobs:
run-tests:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9' ]
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
python-version: [ '3.7', '3.8', '3.9', '3.10', 'pypy-3.7']
exclude:
- os: "windows-latest"
python-version: "pypy-3.7"
- os: "macos-latest"
python-version: "3.8"
steps:
- name: Check out repository code
uses: actions/checkout@v2
- name: Install dependencies
- name: Run base setup actions
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: Install Linux dependencies
if: startsWith(runner.os, 'Linux')
run: |
sudo apt-get update
sudo apt-get install texlive-plain-generic inkscape texlive-xetex

# pandoc is not up to date in the ubuntu repos, so we install directly
wget https://github.com/jgm/pandoc/releases/download/2.14.2/pandoc-2.14.2-1-amd64.deb && sudo dpkg -i pandoc-2.14.2-1-amd64.deb

- name: Install Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: 'x64'
- name: Cache pip on Linux
uses: actions/cache@v2
if: startsWith(runner.os, 'Linux')
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}

- name: Install package dependencies
run: |
pip install --upgrade setuptools pip pytest
pip install -f travis-wheels/wheelhouse . codecov coverage
pip install nbconvert[execute,serve,test]
pip install codecov
pip install -e ".[execute,serve,test]"
pip install check-manifest
python -m ipykernel.kernelspec --user

Expand All @@ -50,14 +45,27 @@ jobs:
pip freeze
pip check

- name: Run tests
- name: Run tests with coverage
if: ${{ !startsWith(matrix.python-version, 'pypy') && !startsWith(runner.os, 'Windows') }}
env:
PYTHONWARNINGS: default
run: |
check-manifest --ignore "share/**"
# See https://github.com/pyppeteer/pyppeteer/pull/321
pip install -U websockets
# cd so we test the install, not the repo
cd $HOME
pytest --cov nbconvert -v --pyargs nbconvert

- name: Run tests on pypy and Windows
if: ${{ startsWith(matrix.python-version, 'pypy') || startsWith(runner.os, 'Windows') }}
shell: bash
run: |
# cd so we test the install, not the repo
cd `mktemp -d`
py.test --cov nbconvert -v --pyargs nbconvert
cd $HOME
# See https://github.com/pyppeteer/pyppeteer/pull/321
pip install -U websockets
pytest -v --pyargs nbconvert

- name: Code coverage
run: codecov
1 change: 1 addition & 0 deletions nbconvert/preprocessors/tests/test_svg2pdf.py
Expand Up @@ -73,6 +73,7 @@ def test_output(self):
nb, res = preprocessor(nb, res)
self.assertIn('application/pdf', nb.cells[0].outputs[0].data)

@onlyif_cmds_exist('inkscape')
@patch('subprocess.Popen')
def test_inkscape_version_default(self, mock_popen):
mock_popen().communicate.return_value = (b'Inkscape 0.92.3 (2405546, 2018-03-11)', b'')
Expand Down
5 changes: 3 additions & 2 deletions nbconvert/tests/test_nbconvertapp.py
Expand Up @@ -287,6 +287,7 @@ def test_filename_accent_pdf(self):
' --PDFExporter.verbose=True')
assert os.path.isfile(u'nb1_análisis.pdf')

@pytest.mark.skipif(os.name == 'nt', reason='CLI parsing does not work the same on Windows')
def test_cwd_plugin(self):
"""
Verify that an extension in the cwd can be imported.
Expand Down Expand Up @@ -553,7 +554,7 @@ def fig_exists(path):

def test_widgets_from_nbconvert(self):
"""Check jupyter widgets URL"""

with self.create_temp_cwd(["Widget_List.ipynb"]):
self.nbconvert('Widget_List.ipynb --log-level 0 --to html')
assert os.path.isfile('Widget_List.html')
Expand All @@ -568,7 +569,7 @@ def test_widgets_from_htmlexporter(self):
nb = nbformat.read(f, 4)

output, _ = HTMLExporter().from_notebook_node(nb)

assert "var widgetRendererSrc = 'https://unpkg.com/@jupyter-widgets/html-manager@*/dist/embed-amd.js';" in output

def test_execute_widgets_from_nbconvert(self):
Expand Down
8 changes: 4 additions & 4 deletions nbconvert/utils/version.py
Expand Up @@ -8,7 +8,7 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.

from distutils.version import LooseVersion
from packaging.version import Version


def check_version(v, min_v, max_v=None):
Expand All @@ -27,9 +27,9 @@ def check_version(v, min_v, max_v=None):
is satisfied. Users on dev branches are responsible for keeping their own
packages up to date.
"""

try:
below_max = LooseVersion(v) < LooseVersion(max_v) if max_v is not None else True
return LooseVersion(v) >= LooseVersion(min_v) and below_max
below_max = Version(v) < Version(max_v) if max_v is not None else True
return Version(v) >= Version(min_v) and below_max
except TypeError:
return True