diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index ae29024a3..139c02c3d 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -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 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index aa982a774..caf0b89d6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,14 +8,24 @@ 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 @@ -23,25 +33,10 @@ jobs: # 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 @@ -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 diff --git a/nbconvert/preprocessors/tests/test_svg2pdf.py b/nbconvert/preprocessors/tests/test_svg2pdf.py index 04890bd9a..4bdce7639 100644 --- a/nbconvert/preprocessors/tests/test_svg2pdf.py +++ b/nbconvert/preprocessors/tests/test_svg2pdf.py @@ -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'') diff --git a/nbconvert/tests/test_nbconvertapp.py b/nbconvert/tests/test_nbconvertapp.py index 48bc173d0..2d5afaa5a 100644 --- a/nbconvert/tests/test_nbconvertapp.py +++ b/nbconvert/tests/test_nbconvertapp.py @@ -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. @@ -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') @@ -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): diff --git a/nbconvert/utils/version.py b/nbconvert/utils/version.py index 63bd14b09..a1aa5df27 100644 --- a/nbconvert/utils/version.py +++ b/nbconvert/utils/version.py @@ -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): @@ -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