Skip to content
This repository has been archived by the owner on Jun 28, 2021. It is now read-only.

Commit

Permalink
Merge pull request #15 from Chilipp/sphinx-3.0
Browse files Browse the repository at this point in the history
Add tests for various sphinx versions
  • Loading branch information
Chilipp committed Apr 8, 2020
2 parents f5a30c1 + 87111fc commit 7a1c4d2
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 17 deletions.
50 changes: 34 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,44 @@
language: python
python:
- "2.7"
- "3.6"
- "3.7"

# necessary for python 3.7, see https://github.com/travis-ci/travis-ci/issues/9815
dist: xenial
sudo: yes
env:
- SPHINX_VERSION=1.5.*
- SPHINX_VERSION=1.6.*
- SPHINX_VERSION=1.7.*
- SPHINX_VERSION=1.8.*
- SPHINX_VERSION=2.0.*
- SPHINX_VERSION=""
matrix:
exclude:
- python: "2.7"

jobs:
include:
- python: "3.8"
env: SPHINX_VERSION=2.4.*
- python: "3.8"
env: SPHINX_VERSION=3.0.*
- python: "3.8"
env: SPHINX_VERSION=""
- python: "3.7"
env: SPHINX_VERSION=1.7.*
- python: "3.7"
env: SPHINX_VERSION=1.8.*
- python: "3.7"
env: SPHINX_VERSION=2.0.*
- python: "3.7"
env: SPHINX_VERSION=1.5.*
env: SPHINX_VERSION=2.1.*
- python: "3.7"
env: SPHINX_VERSION=2.2.*
- python: "3.7"
env: SPHINX_VERSION=2.3.*
- python: "3.7"
env: SPHINX_VERSION=2.4.*
- python: "3.7"
env: SPHINX_VERSION=3.0.*
- python: "3.7"
env: SPHINX_VERSION=""
- python: "2.7"
env: SPHINX_VERSION=1.5.*
- python: "2.7"
env: SPHINX_VERSION=1.6.*
- python: "2.7"
env: SPHINX_VERSION=1.7.*
- python: "2.7"
env: SPHINX_VERSION=1.8.*
- python: "2.7"
env: SPHINX_VERSION=""
addons:
apt:
packages:
Expand Down
5 changes: 4 additions & 1 deletion sphinx_nbexamples/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,10 @@ def setup(app):

app.add_config_value('example_gallery_config', gallery_config, 'html')

app.add_stylesheet('example_gallery_styles.css')
if int(sphinx.__version__.split('.')[0]) >= 3:
app.add_css_file('example_gallery_styles.css')
else:
app.add_stylesheet('example_gallery_styles.css')

app.add_directive('linkgalleries', LinkGalleriesDirective)

Expand Down
22 changes: 22 additions & 0 deletions tests/test_sphinx_nbexamples.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def setUp(self):
os.rmdir(self.src_dir)
self.out_dir = osp.join(self.src_dir, 'build', 'html')
shutil.copytree(sphinx_supp, self.src_dir)

self.app = Sphinx(
srcdir=self.src_dir, confdir=self.src_dir, outdir=self.out_dir,
doctreedir=osp.join(self.src_dir, 'build', 'doctrees'),
Expand Down Expand Up @@ -219,6 +220,27 @@ def test_bash(self):
self.assertIn('hello, world', rst)


class TestWarnings(BaseTest):

def setUp(self):
pass

def _setUp(self):
super().setUp()

@unittest.skipIf(int(sphinx.__version__.split('.')[0]) != 3,
"Test implemented for sphinx 3.0")
@unittest.expectedFailure
def test_stylesheet_warning(self):
"""Test whether the app.add_stylesheet() warning is triggered
See https://github.com/Chilipp/sphinx-nbexamples/issues/14"""
from sphinx.application import RemovedInSphinx40Warning
self.assertWarnsRegex(
RemovedInSphinx40Warning, '.*Please use app.add_css_file',
self._setUp)


@unittest.skipIf(pathlib is None, 'The pathlib package is required!')
class TestLinkGalleries(BaseTest):

Expand Down

0 comments on commit 7a1c4d2

Please sign in to comment.