Show More
@@ -11,7 +11,7 b' before_install:' | |||
|
11 | 11 | # Pierre Carrier's PPA for PhantomJS and CasperJS |
|
12 | 12 | - sudo add-apt-repository -y ppa:pcarrier/ppa |
|
13 | 13 | - sudo apt-get update |
|
14 | - sudo apt-get install pandoc casperjs | |
|
14 | - sudo apt-get install pandoc casperjs nodejs | |
|
15 | 15 | install: |
|
16 | 16 | - python setup.py install -q |
|
17 | 17 | script: |
@@ -11,6 +11,7 b'' | |||
|
11 | 11 | # Imports |
|
12 | 12 | #----------------------------------------------------------------------------- |
|
13 | 13 | |
|
14 | import logging | |
|
14 | 15 | import os |
|
15 | 16 | from tempfile import NamedTemporaryFile |
|
16 | 17 | |
@@ -31,7 +32,7 b' def test_help_output():' | |||
|
31 | 32 | tt.help_all_output_test('notebook') |
|
32 | 33 | |
|
33 | 34 | def test_server_info_file(): |
|
34 | nbapp = NotebookApp(profile='nbserver_file_test') | |
|
35 | nbapp = NotebookApp(profile='nbserver_file_test', log=logging.getLogger()) | |
|
35 | 36 | def get_servers(): |
|
36 | 37 | return list(notebookapp.list_running_servers(profile='nbserver_file_test')) |
|
37 | 38 | nbapp.initialize(argv=[]) |
@@ -14,7 +14,7 b'' | |||
|
14 | 14 | |
|
15 | 15 | import os |
|
16 | 16 | |
|
17 |
from IPython.testing.decorators import onlyif_cmd |
|
|
17 | from IPython.testing.decorators import onlyif_any_cmd_exists | |
|
18 | 18 | |
|
19 | 19 | from ...tests.base import TestsBase |
|
20 | 20 | |
@@ -39,7 +39,7 b' class ExportersTestsBase(TestsBase):' | |||
|
39 | 39 | def _get_notebook(self, nb_name='notebook2.ipynb'): |
|
40 | 40 | return os.path.join(self._get_files_path(), nb_name) |
|
41 | 41 | |
|
42 |
@onlyif_cmd |
|
|
42 | @onlyif_any_cmd_exists('nodejs', 'node', 'pandoc') | |
|
43 | 43 | def test_raw_cell_inclusion(self): |
|
44 | 44 | """test raw cell inclusion based on raw_mimetype metadata""" |
|
45 | 45 | if self.should_include_raw is None: |
@@ -14,7 +14,7 b'' | |||
|
14 | 14 | |
|
15 | 15 | from .base import ExportersTestsBase |
|
16 | 16 | from ..html import HTMLExporter |
|
17 |
from IPython.testing.decorators import onlyif_cmd |
|
|
17 | from IPython.testing.decorators import onlyif_any_cmd_exists | |
|
18 | 18 | |
|
19 | 19 | #----------------------------------------------------------------------------- |
|
20 | 20 | # Class |
@@ -33,7 +33,7 b' class TestHTMLExporter(ExportersTestsBase):' | |||
|
33 | 33 | HTMLExporter() |
|
34 | 34 | |
|
35 | 35 | |
|
36 |
@onlyif_cmd |
|
|
36 | @onlyif_any_cmd_exists('nodejs', 'node', 'pandoc') | |
|
37 | 37 | def test_export(self): |
|
38 | 38 | """ |
|
39 | 39 | Can a HTMLExporter export something? |
@@ -42,7 +42,7 b' class TestHTMLExporter(ExportersTestsBase):' | |||
|
42 | 42 | assert len(output) > 0 |
|
43 | 43 | |
|
44 | 44 | |
|
45 |
@onlyif_cmd |
|
|
45 | @onlyif_any_cmd_exists('nodejs', 'node', 'pandoc') | |
|
46 | 46 | def test_export_basic(self): |
|
47 | 47 | """ |
|
48 | 48 | Can a HTMLExporter export using the 'basic' template? |
@@ -51,7 +51,7 b' class TestHTMLExporter(ExportersTestsBase):' | |||
|
51 | 51 | assert len(output) > 0 |
|
52 | 52 | |
|
53 | 53 | |
|
54 |
@onlyif_cmd |
|
|
54 | @onlyif_any_cmd_exists('nodejs', 'node', 'pandoc') | |
|
55 | 55 | def test_export_full(self): |
|
56 | 56 | """ |
|
57 | 57 | Can a HTMLExporter export using the 'full' template? |
@@ -14,7 +14,7 b'' | |||
|
14 | 14 | |
|
15 | 15 | from .base import ExportersTestsBase |
|
16 | 16 | from ..slides import SlidesExporter |
|
17 |
from IPython.testing.decorators import onlyif_cmd |
|
|
17 | from IPython.testing.decorators import onlyif_any_cmd_exists | |
|
18 | 18 | |
|
19 | 19 | #----------------------------------------------------------------------------- |
|
20 | 20 | # Class |
@@ -33,7 +33,7 b' class TestSlidesExporter(ExportersTestsBase):' | |||
|
33 | 33 | SlidesExporter() |
|
34 | 34 | |
|
35 | 35 | |
|
36 |
@onlyif_cmd |
|
|
36 | @onlyif_any_cmd_exists('nodejs', 'node', 'pandoc') | |
|
37 | 37 | def test_export(self): |
|
38 | 38 | """ |
|
39 | 39 | Can a SlidesExporter export something? |
@@ -42,7 +42,7 b' class TestSlidesExporter(ExportersTestsBase):' | |||
|
42 | 42 | assert len(output) > 0 |
|
43 | 43 | |
|
44 | 44 | |
|
45 |
@onlyif_cmd |
|
|
45 | @onlyif_any_cmd_exists('nodejs', 'node', 'pandoc') | |
|
46 | 46 | def test_export_reveal(self): |
|
47 | 47 | """ |
|
48 | 48 | Can a SlidesExporter export using the 'reveal' template? |
@@ -14,6 +14,7 b' Module with tests for the PDF post-processor' | |||
|
14 | 14 | # Imports |
|
15 | 15 | #----------------------------------------------------------------------------- |
|
16 | 16 | |
|
17 | import logging | |
|
17 | 18 | import os |
|
18 | 19 | |
|
19 | 20 | from IPython.testing import decorators as dec |
@@ -56,7 +57,7 b' class TestPDF(TestsBase):' | |||
|
56 | 57 | f.write(HELLO_WORLD) |
|
57 | 58 | |
|
58 | 59 | # Construct post-processor |
|
59 | processor = PDFPostProcessor() | |
|
60 | processor = PDFPostProcessor(log=logging.getLogger()) | |
|
60 | 61 | processor.verbose = False |
|
61 | 62 | processor('a.tex') |
|
62 | 63 |
@@ -21,12 +21,6 b' from .base import TestsBase' | |||
|
21 | 21 | import IPython.testing.tools as tt |
|
22 | 22 | from IPython.testing import decorators as dec |
|
23 | 23 | |
|
24 | ||
|
25 | #----------------------------------------------------------------------------- | |
|
26 | # Constants | |
|
27 | #----------------------------------------------------------------------------- | |
|
28 | ||
|
29 | ||
|
30 | 24 | #----------------------------------------------------------------------------- |
|
31 | 25 | # Classes and functions |
|
32 | 26 | #----------------------------------------------------------------------------- |
@@ -85,7 +79,7 b' class TestNbConvertApp(TestsBase):' | |||
|
85 | 79 | """ |
|
86 | 80 | with self.create_temp_cwd(['notebook2.ipynb']): |
|
87 | 81 | os.rename('notebook2.ipynb', 'notebook with spaces.ipynb') |
|
88 |
|
|
|
82 | self.call('nbconvert --log-level 0 --to latex ' | |
|
89 | 83 | '"notebook with spaces" --post PDF ' |
|
90 | 84 | '--PDFPostProcessor.verbose=True') |
|
91 | 85 | assert os.path.isfile('notebook with spaces.tex') |
@@ -194,15 +188,14 b' class TestNbConvertApp(TestsBase):' | |||
|
194 | 188 | self.call('nbconvert --log-level 0 --to python nb1_*') |
|
195 | 189 | assert os.path.isfile(u'nb1_análisis.py') |
|
196 | 190 | |
|
197 | @dec.onlyif_cmds_exist('pdflatex') | |
|
198 | @dec.onlyif_cmds_exist('pandoc') | |
|
199 | def test_filename_accent(self): | |
|
191 | @dec.onlyif_cmds_exist('pdflatex', 'pandoc') | |
|
192 | def test_filename_accent_pdf(self): | |
|
200 | 193 | """ |
|
201 | 194 | Generate PDFs if notebooks have an accent in their name? |
|
202 | 195 | """ |
|
203 | 196 | with self.create_temp_cwd(): |
|
204 | 197 | self.create_empty_notebook(u'nb1_análisis.ipynb') |
|
205 |
|
|
|
198 | self.call('nbconvert --log-level 0 --to latex ' | |
|
206 | 199 | '"nb1_*" --post PDF ' |
|
207 | 200 | '--PDFPostProcessor.verbose=True') |
|
208 | 201 | assert os.path.isfile(u'nb1_análisis.tex') |
@@ -10,6 +10,7 b'' | |||
|
10 | 10 | # Imports |
|
11 | 11 | #----------------------------------------------------------------------------- |
|
12 | 12 | import os |
|
13 | import warnings | |
|
13 | 14 | |
|
14 | 15 | from IPython.testing import decorators as dec |
|
15 | 16 | |
@@ -32,22 +33,29 b' class TestPandoc(TestsBase):' | |||
|
32 | 33 | pandoc.clean_cache() |
|
33 | 34 | |
|
34 | 35 | os.environ["PATH"] = "" |
|
35 | assert pandoc_function_raised_missing(pandoc.get_pandoc_version) == True | |
|
36 | assert pandoc_function_raised_missing(pandoc.check_pandoc_version) == True | |
|
37 | assert pandoc_function_raised_missing(pandoc.pandoc, "", "markdown", "html") == True | |
|
36 | with self.assertRaises(pandoc.PandocMissing): | |
|
37 | pandoc.get_pandoc_version() | |
|
38 | with self.assertRaises(pandoc.PandocMissing): | |
|
39 | pandoc.check_pandoc_version() | |
|
40 | with self.assertRaises(pandoc.PandocMissing): | |
|
41 | pandoc.pandoc("", "markdown", "html") | |
|
38 | 42 | |
|
39 | 43 | # original_env["PATH"] should contain pandoc |
|
40 | 44 | os.environ["PATH"] = self.original_env["PATH"] |
|
41 | assert pandoc_function_raised_missing(pandoc.get_pandoc_version) == False | |
|
42 | assert pandoc_function_raised_missing(pandoc.check_pandoc_version) == False | |
|
43 | assert pandoc_function_raised_missing(pandoc.pandoc, "", "markdown", "html") == False | |
|
45 | with warnings.catch_warnings(record=True) as w: | |
|
46 | pandoc.get_pandoc_version() | |
|
47 | pandoc.check_pandoc_version() | |
|
48 | pandoc.pandoc("", "markdown", "html") | |
|
49 | self.assertEqual(w, []) | |
|
44 | 50 | |
|
45 | 51 | @dec.onlyif_cmds_exist('pandoc') |
|
46 | 52 | def test_minimal_version(self): |
|
47 | 53 | original_minversion = pandoc._minimal_version |
|
48 | ||
|
54 | ||
|
49 | 55 | pandoc._minimal_version = "120.0" |
|
50 | assert not pandoc.check_pandoc_version() | |
|
56 | with warnings.catch_warnings(record=True) as w: | |
|
57 | assert not pandoc.check_pandoc_version() | |
|
58 | self.assertEqual(len(w), 1) | |
|
51 | 59 | |
|
52 | 60 | pandoc._minimal_version = pandoc.get_pandoc_version() |
|
53 | 61 | assert pandoc.check_pandoc_version() |
@@ -381,3 +381,20 b' def onlyif_cmds_exist(*commands):' | |||
|
381 | 381 | "is installed".format(cmd)) |
|
382 | 382 | raise e |
|
383 | 383 | return null_deco |
|
384 | ||
|
385 | def onlyif_any_cmd_exists(*commands): | |
|
386 | """ | |
|
387 | Decorator to skip test unless at least one of `commands` is found. | |
|
388 | """ | |
|
389 | for cmd in commands: | |
|
390 | try: | |
|
391 | if is_cmd_found(cmd): | |
|
392 | return null_deco | |
|
393 | except ImportError as e: | |
|
394 | # is_cmd_found uses pywin32 on windows, which might not be available | |
|
395 | if sys.platform == 'win32' and 'pywin32' in str(e): | |
|
396 | return skip("This test runs only if pywin32 and commands '{0}' " | |
|
397 | "are installed".format(commands)) | |
|
398 | raise e | |
|
399 | return skip("This test runs only if one of the commands {0} " | |
|
400 | "is installed".format(commands)) |
General Comments 0
You need to be logged in to leave comments.
Login now