mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-12 11:45:38 +08:00
Merge pull request #4739 from minrk/skip-without-pandoc
skip html nbconvert tests when their dependencies are missing
This commit is contained in:
commit
8faa0d45be
@ -14,6 +14,9 @@ from IPython.nbformat.current import (new_notebook, write, new_worksheet,
|
|||||||
new_heading_cell, new_code_cell,
|
new_heading_cell, new_code_cell,
|
||||||
new_output)
|
new_output)
|
||||||
|
|
||||||
|
from IPython.testing.decorators import onlyif_cmds_exist
|
||||||
|
|
||||||
|
|
||||||
class NbconvertAPI(object):
|
class NbconvertAPI(object):
|
||||||
"""Wrapper for nbconvert API calls."""
|
"""Wrapper for nbconvert API calls."""
|
||||||
def __init__(self, base_url):
|
def __init__(self, base_url):
|
||||||
@ -71,6 +74,7 @@ class APITest(NotebookTestBase):
|
|||||||
for dname in ['foo']:
|
for dname in ['foo']:
|
||||||
shutil.rmtree(pjoin(nbdir, dname), ignore_errors=True)
|
shutil.rmtree(pjoin(nbdir, dname), ignore_errors=True)
|
||||||
|
|
||||||
|
@onlyif_cmds_exist('pandoc')
|
||||||
def test_from_file(self):
|
def test_from_file(self):
|
||||||
r = self.nbconvert_api.from_file('html', 'foo', 'testnb.ipynb')
|
r = self.nbconvert_api.from_file('html', 'foo', 'testnb.ipynb')
|
||||||
self.assertEqual(r.status_code, 200)
|
self.assertEqual(r.status_code, 200)
|
||||||
@ -82,21 +86,25 @@ class APITest(NotebookTestBase):
|
|||||||
self.assertIn(u'text/x-python', r.headers['Content-Type'])
|
self.assertIn(u'text/x-python', r.headers['Content-Type'])
|
||||||
self.assertIn(u'print(2*6)', r.text)
|
self.assertIn(u'print(2*6)', r.text)
|
||||||
|
|
||||||
|
@onlyif_cmds_exist('pandoc')
|
||||||
def test_from_file_404(self):
|
def test_from_file_404(self):
|
||||||
with assert_http_error(404):
|
with assert_http_error(404):
|
||||||
self.nbconvert_api.from_file('html', 'foo', 'thisdoesntexist.ipynb')
|
self.nbconvert_api.from_file('html', 'foo', 'thisdoesntexist.ipynb')
|
||||||
|
|
||||||
|
@onlyif_cmds_exist('pandoc')
|
||||||
def test_from_file_download(self):
|
def test_from_file_download(self):
|
||||||
r = self.nbconvert_api.from_file('python', 'foo', 'testnb.ipynb', download=True)
|
r = self.nbconvert_api.from_file('python', 'foo', 'testnb.ipynb', download=True)
|
||||||
content_disposition = r.headers['Content-Disposition']
|
content_disposition = r.headers['Content-Disposition']
|
||||||
self.assertIn('attachment', content_disposition)
|
self.assertIn('attachment', content_disposition)
|
||||||
self.assertIn('testnb.py', content_disposition)
|
self.assertIn('testnb.py', content_disposition)
|
||||||
|
|
||||||
|
@onlyif_cmds_exist('pandoc')
|
||||||
def test_from_file_zip(self):
|
def test_from_file_zip(self):
|
||||||
r = self.nbconvert_api.from_file('latex', 'foo', 'testnb.ipynb', download=True)
|
r = self.nbconvert_api.from_file('latex', 'foo', 'testnb.ipynb', download=True)
|
||||||
self.assertIn(u'application/zip', r.headers['Content-Type'])
|
self.assertIn(u'application/zip', r.headers['Content-Type'])
|
||||||
self.assertIn(u'.zip', r.headers['Content-Disposition'])
|
self.assertIn(u'.zip', r.headers['Content-Disposition'])
|
||||||
|
|
||||||
|
@onlyif_cmds_exist('pandoc')
|
||||||
def test_from_post(self):
|
def test_from_post(self):
|
||||||
nbmodel_url = url_path_join(self.base_url(), 'api/notebooks/foo/testnb.ipynb')
|
nbmodel_url = url_path_join(self.base_url(), 'api/notebooks/foo/testnb.ipynb')
|
||||||
nbmodel = requests.get(nbmodel_url).json()
|
nbmodel = requests.get(nbmodel_url).json()
|
||||||
@ -111,6 +119,7 @@ class APITest(NotebookTestBase):
|
|||||||
self.assertIn(u'text/x-python', r.headers['Content-Type'])
|
self.assertIn(u'text/x-python', r.headers['Content-Type'])
|
||||||
self.assertIn(u'print(2*6)', r.text)
|
self.assertIn(u'print(2*6)', r.text)
|
||||||
|
|
||||||
|
@onlyif_cmds_exist('pandoc')
|
||||||
def test_from_post_zip(self):
|
def test_from_post_zip(self):
|
||||||
nbmodel_url = url_path_join(self.base_url(), 'api/notebooks/foo/testnb.ipynb')
|
nbmodel_url = url_path_join(self.base_url(), 'api/notebooks/foo/testnb.ipynb')
|
||||||
nbmodel = requests.get(nbmodel_url).json()
|
nbmodel = requests.get(nbmodel_url).json()
|
||||||
|
@ -280,6 +280,8 @@ if not have['jinja2']:
|
|||||||
sec.exclude('notebookapp')
|
sec.exclude('notebookapp')
|
||||||
if not have['azure']:
|
if not have['azure']:
|
||||||
sec.exclude('services.notebooks.azurenbmanager')
|
sec.exclude('services.notebooks.azurenbmanager')
|
||||||
|
if not have['pygments'] or not have['jinja2']:
|
||||||
|
sec.exclude('nbconvert')
|
||||||
|
|
||||||
# config:
|
# config:
|
||||||
# Config files aren't really importable stand-alone
|
# Config files aren't really importable stand-alone
|
||||||
@ -287,7 +289,7 @@ test_sections['config'].exclude('profile')
|
|||||||
|
|
||||||
# nbconvert:
|
# nbconvert:
|
||||||
sec = test_sections['nbconvert']
|
sec = test_sections['nbconvert']
|
||||||
sec.requires('pygments', 'jinja2', 'sphinx')
|
sec.requires('pygments', 'jinja2')
|
||||||
# Exclude nbconvert directories containing config files used to test.
|
# Exclude nbconvert directories containing config files used to test.
|
||||||
# Executing the config files with iptest would cause an exception.
|
# Executing the config files with iptest would cause an exception.
|
||||||
sec.exclude('tests.files')
|
sec.exclude('tests.files')
|
||||||
|
Loading…
Reference in New Issue
Block a user