##// END OF EJS Templates
Merge pull request #5203 from minrk/test-log-warn...
Thomas Kluyver -
r15511:7a1f3e2c merge
parent child Browse files
Show More
@@ -11,7 +11,7 b' before_install:'
11 # Pierre Carrier's PPA for PhantomJS and CasperJS
11 # Pierre Carrier's PPA for PhantomJS and CasperJS
12 - sudo add-apt-repository -y ppa:pcarrier/ppa
12 - sudo add-apt-repository -y ppa:pcarrier/ppa
13 - sudo apt-get update
13 - sudo apt-get update
14 - sudo apt-get install pandoc casperjs
14 - sudo apt-get install pandoc casperjs nodejs
15 install:
15 install:
16 - python setup.py install -q
16 - python setup.py install -q
17 script:
17 script:
@@ -11,6 +11,7 b''
11 # Imports
11 # Imports
12 #-----------------------------------------------------------------------------
12 #-----------------------------------------------------------------------------
13
13
14 import logging
14 import os
15 import os
15 from tempfile import NamedTemporaryFile
16 from tempfile import NamedTemporaryFile
16
17
@@ -31,7 +32,7 b' def test_help_output():'
31 tt.help_all_output_test('notebook')
32 tt.help_all_output_test('notebook')
32
33
33 def test_server_info_file():
34 def test_server_info_file():
34 nbapp = NotebookApp(profile='nbserver_file_test')
35 nbapp = NotebookApp(profile='nbserver_file_test', log=logging.getLogger())
35 def get_servers():
36 def get_servers():
36 return list(notebookapp.list_running_servers(profile='nbserver_file_test'))
37 return list(notebookapp.list_running_servers(profile='nbserver_file_test'))
37 nbapp.initialize(argv=[])
38 nbapp.initialize(argv=[])
@@ -14,7 +14,7 b''
14
14
15 import os
15 import os
16
16
17 from IPython.testing.decorators import onlyif_cmds_exist
17 from IPython.testing.decorators import onlyif_any_cmd_exists
18
18
19 from ...tests.base import TestsBase
19 from ...tests.base import TestsBase
20
20
@@ -39,7 +39,7 b' class ExportersTestsBase(TestsBase):'
39 def _get_notebook(self, nb_name='notebook2.ipynb'):
39 def _get_notebook(self, nb_name='notebook2.ipynb'):
40 return os.path.join(self._get_files_path(), nb_name)
40 return os.path.join(self._get_files_path(), nb_name)
41
41
42 @onlyif_cmds_exist('pandoc')
42 @onlyif_any_cmd_exists('nodejs', 'node', 'pandoc')
43 def test_raw_cell_inclusion(self):
43 def test_raw_cell_inclusion(self):
44 """test raw cell inclusion based on raw_mimetype metadata"""
44 """test raw cell inclusion based on raw_mimetype metadata"""
45 if self.should_include_raw is None:
45 if self.should_include_raw is None:
@@ -14,7 +14,7 b''
14
14
15 from .base import ExportersTestsBase
15 from .base import ExportersTestsBase
16 from ..html import HTMLExporter
16 from ..html import HTMLExporter
17 from IPython.testing.decorators import onlyif_cmds_exist
17 from IPython.testing.decorators import onlyif_any_cmd_exists
18
18
19 #-----------------------------------------------------------------------------
19 #-----------------------------------------------------------------------------
20 # Class
20 # Class
@@ -33,7 +33,7 b' class TestHTMLExporter(ExportersTestsBase):'
33 HTMLExporter()
33 HTMLExporter()
34
34
35
35
36 @onlyif_cmds_exist('pandoc')
36 @onlyif_any_cmd_exists('nodejs', 'node', 'pandoc')
37 def test_export(self):
37 def test_export(self):
38 """
38 """
39 Can a HTMLExporter export something?
39 Can a HTMLExporter export something?
@@ -42,7 +42,7 b' class TestHTMLExporter(ExportersTestsBase):'
42 assert len(output) > 0
42 assert len(output) > 0
43
43
44
44
45 @onlyif_cmds_exist('pandoc')
45 @onlyif_any_cmd_exists('nodejs', 'node', 'pandoc')
46 def test_export_basic(self):
46 def test_export_basic(self):
47 """
47 """
48 Can a HTMLExporter export using the 'basic' template?
48 Can a HTMLExporter export using the 'basic' template?
@@ -51,7 +51,7 b' class TestHTMLExporter(ExportersTestsBase):'
51 assert len(output) > 0
51 assert len(output) > 0
52
52
53
53
54 @onlyif_cmds_exist('pandoc')
54 @onlyif_any_cmd_exists('nodejs', 'node', 'pandoc')
55 def test_export_full(self):
55 def test_export_full(self):
56 """
56 """
57 Can a HTMLExporter export using the 'full' template?
57 Can a HTMLExporter export using the 'full' template?
@@ -14,7 +14,7 b''
14
14
15 from .base import ExportersTestsBase
15 from .base import ExportersTestsBase
16 from ..slides import SlidesExporter
16 from ..slides import SlidesExporter
17 from IPython.testing.decorators import onlyif_cmds_exist
17 from IPython.testing.decorators import onlyif_any_cmd_exists
18
18
19 #-----------------------------------------------------------------------------
19 #-----------------------------------------------------------------------------
20 # Class
20 # Class
@@ -33,7 +33,7 b' class TestSlidesExporter(ExportersTestsBase):'
33 SlidesExporter()
33 SlidesExporter()
34
34
35
35
36 @onlyif_cmds_exist('pandoc')
36 @onlyif_any_cmd_exists('nodejs', 'node', 'pandoc')
37 def test_export(self):
37 def test_export(self):
38 """
38 """
39 Can a SlidesExporter export something?
39 Can a SlidesExporter export something?
@@ -42,7 +42,7 b' class TestSlidesExporter(ExportersTestsBase):'
42 assert len(output) > 0
42 assert len(output) > 0
43
43
44
44
45 @onlyif_cmds_exist('pandoc')
45 @onlyif_any_cmd_exists('nodejs', 'node', 'pandoc')
46 def test_export_reveal(self):
46 def test_export_reveal(self):
47 """
47 """
48 Can a SlidesExporter export using the 'reveal' template?
48 Can a SlidesExporter export using the 'reveal' template?
@@ -14,6 +14,7 b' Module with tests for the PDF post-processor'
14 # Imports
14 # Imports
15 #-----------------------------------------------------------------------------
15 #-----------------------------------------------------------------------------
16
16
17 import logging
17 import os
18 import os
18
19
19 from IPython.testing import decorators as dec
20 from IPython.testing import decorators as dec
@@ -56,7 +57,7 b' class TestPDF(TestsBase):'
56 f.write(HELLO_WORLD)
57 f.write(HELLO_WORLD)
57
58
58 # Construct post-processor
59 # Construct post-processor
59 processor = PDFPostProcessor()
60 processor = PDFPostProcessor(log=logging.getLogger())
60 processor.verbose = False
61 processor.verbose = False
61 processor('a.tex')
62 processor('a.tex')
62
63
@@ -21,12 +21,6 b' from .base import TestsBase'
21 import IPython.testing.tools as tt
21 import IPython.testing.tools as tt
22 from IPython.testing import decorators as dec
22 from IPython.testing import decorators as dec
23
23
24
25 #-----------------------------------------------------------------------------
26 # Constants
27 #-----------------------------------------------------------------------------
28
29
30 #-----------------------------------------------------------------------------
24 #-----------------------------------------------------------------------------
31 # Classes and functions
25 # Classes and functions
32 #-----------------------------------------------------------------------------
26 #-----------------------------------------------------------------------------
@@ -85,7 +79,7 b' class TestNbConvertApp(TestsBase):'
85 """
79 """
86 with self.create_temp_cwd(['notebook2.ipynb']):
80 with self.create_temp_cwd(['notebook2.ipynb']):
87 os.rename('notebook2.ipynb', 'notebook with spaces.ipynb')
81 os.rename('notebook2.ipynb', 'notebook with spaces.ipynb')
88 o,e = self.call('nbconvert --log-level 0 --to latex '
82 self.call('nbconvert --log-level 0 --to latex '
89 '"notebook with spaces" --post PDF '
83 '"notebook with spaces" --post PDF '
90 '--PDFPostProcessor.verbose=True')
84 '--PDFPostProcessor.verbose=True')
91 assert os.path.isfile('notebook with spaces.tex')
85 assert os.path.isfile('notebook with spaces.tex')
@@ -194,15 +188,14 b' class TestNbConvertApp(TestsBase):'
194 self.call('nbconvert --log-level 0 --to python nb1_*')
188 self.call('nbconvert --log-level 0 --to python nb1_*')
195 assert os.path.isfile(u'nb1_análisis.py')
189 assert os.path.isfile(u'nb1_análisis.py')
196
190
197 @dec.onlyif_cmds_exist('pdflatex')
191 @dec.onlyif_cmds_exist('pdflatex', 'pandoc')
198 @dec.onlyif_cmds_exist('pandoc')
192 def test_filename_accent_pdf(self):
199 def test_filename_accent(self):
200 """
193 """
201 Generate PDFs if notebooks have an accent in their name?
194 Generate PDFs if notebooks have an accent in their name?
202 """
195 """
203 with self.create_temp_cwd():
196 with self.create_temp_cwd():
204 self.create_empty_notebook(u'nb1_análisis.ipynb')
197 self.create_empty_notebook(u'nb1_análisis.ipynb')
205 o,e = self.call('nbconvert --log-level 0 --to latex '
198 self.call('nbconvert --log-level 0 --to latex '
206 '"nb1_*" --post PDF '
199 '"nb1_*" --post PDF '
207 '--PDFPostProcessor.verbose=True')
200 '--PDFPostProcessor.verbose=True')
208 assert os.path.isfile(u'nb1_análisis.tex')
201 assert os.path.isfile(u'nb1_análisis.tex')
@@ -10,6 +10,7 b''
10 # Imports
10 # Imports
11 #-----------------------------------------------------------------------------
11 #-----------------------------------------------------------------------------
12 import os
12 import os
13 import warnings
13
14
14 from IPython.testing import decorators as dec
15 from IPython.testing import decorators as dec
15
16
@@ -32,22 +33,29 b' class TestPandoc(TestsBase):'
32 pandoc.clean_cache()
33 pandoc.clean_cache()
33
34
34 os.environ["PATH"] = ""
35 os.environ["PATH"] = ""
35 assert pandoc_function_raised_missing(pandoc.get_pandoc_version) == True
36 with self.assertRaises(pandoc.PandocMissing):
36 assert pandoc_function_raised_missing(pandoc.check_pandoc_version) == True
37 pandoc.get_pandoc_version()
37 assert pandoc_function_raised_missing(pandoc.pandoc, "", "markdown", "html") == True
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 # original_env["PATH"] should contain pandoc
43 # original_env["PATH"] should contain pandoc
40 os.environ["PATH"] = self.original_env["PATH"]
44 os.environ["PATH"] = self.original_env["PATH"]
41 assert pandoc_function_raised_missing(pandoc.get_pandoc_version) == False
45 with warnings.catch_warnings(record=True) as w:
42 assert pandoc_function_raised_missing(pandoc.check_pandoc_version) == False
46 pandoc.get_pandoc_version()
43 assert pandoc_function_raised_missing(pandoc.pandoc, "", "markdown", "html") == False
47 pandoc.check_pandoc_version()
48 pandoc.pandoc("", "markdown", "html")
49 self.assertEqual(w, [])
44
50
45 @dec.onlyif_cmds_exist('pandoc')
51 @dec.onlyif_cmds_exist('pandoc')
46 def test_minimal_version(self):
52 def test_minimal_version(self):
47 original_minversion = pandoc._minimal_version
53 original_minversion = pandoc._minimal_version
48
54
49 pandoc._minimal_version = "120.0"
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 pandoc._minimal_version = pandoc.get_pandoc_version()
60 pandoc._minimal_version = pandoc.get_pandoc_version()
53 assert pandoc.check_pandoc_version()
61 assert pandoc.check_pandoc_version()
@@ -381,3 +381,20 b' def onlyif_cmds_exist(*commands):'
381 "is installed".format(cmd))
381 "is installed".format(cmd))
382 raise e
382 raise e
383 return null_deco
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