##// END OF EJS Templates
remove obsolete `onlyif_any_cmd_exists` on nbconvert tests...
Min RK -
Show More
@@ -1,54 +1,38 b''
1 """Base TestCase class for testing Exporters"""
1 """Base TestCase class for testing Exporters"""
2
2
3 #-----------------------------------------------------------------------------
3 # Copyright (c) IPython Development Team.
4 # Copyright (c) 2013, the IPython Development Team.
5 #
6 # Distributed under the terms of the Modified BSD License.
4 # Distributed under the terms of the Modified BSD License.
7 #
8 # The full license is in the file COPYING.txt, distributed with this software.
9 #-----------------------------------------------------------------------------
10
11 #-----------------------------------------------------------------------------
12 # Imports
13 #-----------------------------------------------------------------------------
14
5
15 import os
6 import os
16
7
17 from IPython.testing.decorators import onlyif_any_cmd_exists
18
19 from ...tests.base import TestsBase
8 from ...tests.base import TestsBase
20
9
21 #-----------------------------------------------------------------------------
22 # Class
23 #-----------------------------------------------------------------------------
24
25 all_raw_mimetypes = {
10 all_raw_mimetypes = {
26 'text/x-python',
11 'text/x-python',
27 'text/markdown',
12 'text/markdown',
28 'text/html',
13 'text/html',
29 'text/restructuredtext',
14 'text/restructuredtext',
30 'text/latex',
15 'text/latex',
31 }
16 }
32
17
33 class ExportersTestsBase(TestsBase):
18 class ExportersTestsBase(TestsBase):
34 """Contains base test functions for exporters"""
19 """Contains base test functions for exporters"""
35
20
36 exporter_class = None
21 exporter_class = None
37 should_include_raw = None
22 should_include_raw = None
38
23
39 def _get_notebook(self, nb_name='notebook2.ipynb'):
24 def _get_notebook(self, nb_name='notebook2.ipynb'):
40 return os.path.join(self._get_files_path(), nb_name)
25 return os.path.join(self._get_files_path(), nb_name)
41
26
42 @onlyif_any_cmd_exists('nodejs', 'node', 'pandoc')
43 def test_raw_cell_inclusion(self):
27 def test_raw_cell_inclusion(self):
44 """test raw cell inclusion based on raw_mimetype metadata"""
28 """test raw cell inclusion based on raw_mimetype metadata"""
45 if self.should_include_raw is None:
29 if self.should_include_raw is None:
46 return
30 return
47 exporter = self.exporter_class()
31 exporter = self.exporter_class()
48 (output, resources) = exporter.from_filename(self._get_notebook('rawtest.ipynb'))
32 (output, resources) = exporter.from_filename(self._get_notebook('rawtest.ipynb'))
49 for inc in self.should_include_raw:
33 for inc in self.should_include_raw:
50 self.assertIn('raw %s' % inc, output, "should include %s" % inc)
34 self.assertIn('raw %s' % inc, output, "should include %s" % inc)
51 self.assertIn('no raw_mimetype metadata', output)
35 self.assertIn('no raw_mimetype metadata', output)
52 for exc in all_raw_mimetypes.difference(self.should_include_raw):
36 for exc in all_raw_mimetypes.difference(self.should_include_raw):
53 self.assertNotIn('raw %s' % exc, output, "should exclude %s" % exc)
37 self.assertNotIn('raw %s' % exc, output, "should exclude %s" % exc)
54 self.assertNotIn('never be included', output)
38 self.assertNotIn('never be included', output)
@@ -1,86 +1,68 b''
1 """Tests for HTMLExporter"""
1 """Tests for HTMLExporter"""
2
2
3 #-----------------------------------------------------------------------------
3 # Copyright (c) IPython Development Team.
4 # Copyright (c) 2013, the IPython Development Team.
5 #
6 # Distributed under the terms of the Modified BSD License.
4 # Distributed under the terms of the Modified BSD License.
7 #
8 # The full license is in the file COPYING.txt, distributed with this software.
9 #-----------------------------------------------------------------------------
10
11 #-----------------------------------------------------------------------------
12 # Imports
13 #-----------------------------------------------------------------------------
14
5
15 from .base import ExportersTestsBase
6 from .base import ExportersTestsBase
16 from ..html import HTMLExporter
7 from ..html import HTMLExporter
17 from IPython.testing.decorators import onlyif_any_cmd_exists
18 import re
8 import re
19
9
20 #-----------------------------------------------------------------------------
21 # Class
22 #-----------------------------------------------------------------------------
23
10
24 class TestHTMLExporter(ExportersTestsBase):
11 class TestHTMLExporter(ExportersTestsBase):
25 """Tests for HTMLExporter"""
12 """Tests for HTMLExporter"""
26
13
27 exporter_class = HTMLExporter
14 exporter_class = HTMLExporter
28 should_include_raw = ['html']
15 should_include_raw = ['html']
29
16
30 def test_constructor(self):
17 def test_constructor(self):
31 """
18 """
32 Can a HTMLExporter be constructed?
19 Can a HTMLExporter be constructed?
33 """
20 """
34 HTMLExporter()
21 HTMLExporter()
35
22
36
23
37 @onlyif_any_cmd_exists('nodejs', 'node', 'pandoc')
38 def test_export(self):
24 def test_export(self):
39 """
25 """
40 Can a HTMLExporter export something?
26 Can a HTMLExporter export something?
41 """
27 """
42 (output, resources) = HTMLExporter().from_filename(self._get_notebook())
28 (output, resources) = HTMLExporter().from_filename(self._get_notebook())
43 assert len(output) > 0
29 assert len(output) > 0
44
30
45
31
46 @onlyif_any_cmd_exists('nodejs', 'node', 'pandoc')
47 def test_export_basic(self):
32 def test_export_basic(self):
48 """
33 """
49 Can a HTMLExporter export using the 'basic' template?
34 Can a HTMLExporter export using the 'basic' template?
50 """
35 """
51 (output, resources) = HTMLExporter(template_file='basic').from_filename(self._get_notebook())
36 (output, resources) = HTMLExporter(template_file='basic').from_filename(self._get_notebook())
52 assert len(output) > 0
37 assert len(output) > 0
53
38
54
39
55 @onlyif_any_cmd_exists('nodejs', 'node', 'pandoc')
56 def test_export_full(self):
40 def test_export_full(self):
57 """
41 """
58 Can a HTMLExporter export using the 'full' template?
42 Can a HTMLExporter export using the 'full' template?
59 """
43 """
60 (output, resources) = HTMLExporter(template_file='full').from_filename(self._get_notebook())
44 (output, resources) = HTMLExporter(template_file='full').from_filename(self._get_notebook())
61 assert len(output) > 0
45 assert len(output) > 0
62
46
63 @onlyif_any_cmd_exists('nodejs', 'node', 'pandoc')
64 def test_prompt_number(self):
47 def test_prompt_number(self):
65 """
48 """
66 Does HTMLExporter properly format input and output prompts?
49 Does HTMLExporter properly format input and output prompts?
67 """
50 """
68 (output, resources) = HTMLExporter(template_file='full').from_filename(
51 (output, resources) = HTMLExporter(template_file='full').from_filename(
69 self._get_notebook(nb_name="prompt_numbers.ipynb"))
52 self._get_notebook(nb_name="prompt_numbers.ipynb"))
70 in_regex = r"In \[(.*)\]:"
53 in_regex = r"In \[(.*)\]:"
71 out_regex = r"Out\[(.*)\]:"
54 out_regex = r"Out\[(.*)\]:"
72
55
73 ins = ["2", "10", " ", " ", "*", "0"]
56 ins = ["2", "10", " ", " ", "*", "0"]
74 outs = ["10"]
57 outs = ["10"]
75
58
76 assert re.findall(in_regex, output) == ins
59 assert re.findall(in_regex, output) == ins
77 assert re.findall(out_regex, output) == outs
60 assert re.findall(out_regex, output) == outs
78
61
79 @onlyif_any_cmd_exists('nodejs', 'node', 'pandoc')
80 def test_png_metadata(self):
62 def test_png_metadata(self):
81 """
63 """
82 Does HTMLExporter with the 'basic' template treat pngs with width/height metadata correctly?
64 Does HTMLExporter with the 'basic' template treat pngs with width/height metadata correctly?
83 """
65 """
84 (output, resources) = HTMLExporter(template_file='basic').from_filename(
66 (output, resources) = HTMLExporter(template_file='basic').from_filename(
85 self._get_notebook(nb_name="pngmetadata.ipynb"))
67 self._get_notebook(nb_name="pngmetadata.ipynb"))
86 assert len(output) > 0
68 assert len(output) > 0
@@ -1,51 +1,36 b''
1 """Tests for SlidesExporter"""
1 """Tests for SlidesExporter"""
2
2
3 #-----------------------------------------------------------------------------
3 # Copyright (c) IPython Development Team.
4 # Copyright (c) 2013, the IPython Development Team.
5 #
6 # Distributed under the terms of the Modified BSD License.
4 # Distributed under the terms of the Modified BSD License.
7 #
8 # The full license is in the file COPYING.txt, distributed with this software.
9 #-----------------------------------------------------------------------------
10
11 #-----------------------------------------------------------------------------
12 # Imports
13 #-----------------------------------------------------------------------------
14
5
15 from .base import ExportersTestsBase
6 from .base import ExportersTestsBase
16 from ..slides import SlidesExporter
7 from ..slides import SlidesExporter
17 from IPython.testing.decorators import onlyif_any_cmd_exists
18
8
19 #-----------------------------------------------------------------------------
20 # Class
21 #-----------------------------------------------------------------------------
22
9
23 class TestSlidesExporter(ExportersTestsBase):
10 class TestSlidesExporter(ExportersTestsBase):
24 """Tests for SlidesExporter"""
11 """Tests for SlidesExporter"""
25
12
26 exporter_class = SlidesExporter
13 exporter_class = SlidesExporter
27 should_include_raw = ['html']
14 should_include_raw = ['html']
28
15
29 def test_constructor(self):
16 def test_constructor(self):
30 """
17 """
31 Can a SlidesExporter be constructed?
18 Can a SlidesExporter be constructed?
32 """
19 """
33 SlidesExporter()
20 SlidesExporter()
34
21
35
22
36 @onlyif_any_cmd_exists('nodejs', 'node', 'pandoc')
37 def test_export(self):
23 def test_export(self):
38 """
24 """
39 Can a SlidesExporter export something?
25 Can a SlidesExporter export something?
40 """
26 """
41 (output, resources) = SlidesExporter().from_filename(self._get_notebook())
27 (output, resources) = SlidesExporter().from_filename(self._get_notebook())
42 assert len(output) > 0
28 assert len(output) > 0
43
29
44
30
45 @onlyif_any_cmd_exists('nodejs', 'node', 'pandoc')
46 def test_export_reveal(self):
31 def test_export_reveal(self):
47 """
32 """
48 Can a SlidesExporter export using the 'reveal' template?
33 Can a SlidesExporter export using the 'reveal' template?
49 """
34 """
50 (output, resources) = SlidesExporter(template_file='slides_reveal').from_filename(self._get_notebook())
35 (output, resources) = SlidesExporter(template_file='slides_reveal').from_filename(self._get_notebook())
51 assert len(output) > 0
36 assert len(output) > 0
General Comments 0
You need to be logged in to leave comments. Login now