##// END OF EJS Templates
Fixed tests
Jonathan Frederic -
Show More
@@ -1,64 +1,64 b''
1 """
1 """
2 Module with tests for basichtml.py
2 Module with tests for basichtml.py
3 """
3 """
4
4
5 #-----------------------------------------------------------------------------
5 #-----------------------------------------------------------------------------
6 # Copyright (c) 2013, the IPython Development Team.
6 # Copyright (c) 2013, the IPython Development Team.
7 #
7 #
8 # Distributed under the terms of the Modified BSD License.
8 # Distributed under the terms of the Modified BSD License.
9 #
9 #
10 # The full license is in the file COPYING.txt, distributed with this software.
10 # The full license is in the file COPYING.txt, distributed with this software.
11 #-----------------------------------------------------------------------------
11 #-----------------------------------------------------------------------------
12
12
13 #-----------------------------------------------------------------------------
13 #-----------------------------------------------------------------------------
14 # Imports
14 # Imports
15 #-----------------------------------------------------------------------------
15 #-----------------------------------------------------------------------------
16
16
17 from .base import ExportersTestsBase
17 from .base import ExportersTestsBase
18 from ..basichtml import BasicHTMLExporter
18 from ..html import HTMLExporter
19 from IPython.testing.decorators import onlyif_cmds_exist
19 from IPython.testing.decorators import onlyif_cmds_exist
20
20
21 #-----------------------------------------------------------------------------
21 #-----------------------------------------------------------------------------
22 # Class
22 # Class
23 #-----------------------------------------------------------------------------
23 #-----------------------------------------------------------------------------
24
24
25 class TestBasicHTMLExporter(ExportersTestsBase):
25 class TestHTMLExporter(ExportersTestsBase):
26 """Contains test functions for basichtml.py"""
26 """Contains test functions for basichtml.py"""
27
27
28 def test_constructor(self):
28 def test_constructor(self):
29 """
29 """
30 Can a BasicHTMLExporter be constructed?
30 Can a HTMLExporter be constructed?
31 """
31 """
32 BasicHTMLExporter()
32 HTMLExporter()
33
33
34 @onlyif_cmds_exist('pandoc')
34 @onlyif_cmds_exist('pandoc')
35 def test_export(self):
35 def test_export(self):
36 """
36 """
37 Can a BasicHTMLExporter export something?
37 Can a HTMLExporter export something?
38 """
38 """
39 (output, resources) = BasicHTMLExporter().from_filename(self._get_notebook())
39 (output, resources) = HTMLExporter().from_filename(self._get_notebook())
40 assert len(output) > 0
40 assert len(output) > 0
41
41
42
42
43 def test_export_basic(self):
43 def test_export_basic(self):
44 """
44 """
45 Can a BasicHTMLExporter export using the 'basic' flavor?
45 Can a HTMLExporter export using the 'basic' flavor?
46 """
46 """
47 (output, resources) = BasicHTMLExporter(flavor='basic').from_filename(self._get_notebook())
47 (output, resources) = HTMLExporter(flavor='basic').from_filename(self._get_notebook())
48 assert len(output) > 0
48 assert len(output) > 0
49
49
50
50
51 def test_export_full(self):
51 def test_export_full(self):
52 """
52 """
53 Can a BasicHTMLExporter export using the 'full' flavor?
53 Can a HTMLExporter export using the 'full' flavor?
54 """
54 """
55 (output, resources) = BasicHTMLExporter(flavor='full').from_filename(self._get_notebook())
55 (output, resources) = HTMLExporter(flavor='full').from_filename(self._get_notebook())
56 assert len(output) > 0
56 assert len(output) > 0
57
57
58
58
59 def test_export_reveal(self):
59 def test_export_reveal(self):
60 """
60 """
61 Can a BasicHTMLExporter export using the 'reveal' flavor?
61 Can a HTMLExporter export using the 'reveal' flavor?
62 """
62 """
63 (output, resources) = BasicHTMLExporter(flavor='reveal').from_filename(self._get_notebook())
63 (output, resources) = HTMLExporter(flavor='reveal').from_filename(self._get_notebook())
64 assert len(output) > 0 No newline at end of file
64 assert len(output) > 0
@@ -1,65 +1,65 b''
1 """
1 """
2 Module with tests for latex.py
2 Module with tests for latex.py
3 """
3 """
4
4
5 #-----------------------------------------------------------------------------
5 #-----------------------------------------------------------------------------
6 # Copyright (c) 2013, the IPython Development Team.
6 # Copyright (c) 2013, the IPython Development Team.
7 #
7 #
8 # Distributed under the terms of the Modified BSD License.
8 # Distributed under the terms of the Modified BSD License.
9 #
9 #
10 # The full license is in the file COPYING.txt, distributed with this software.
10 # The full license is in the file COPYING.txt, distributed with this software.
11 #-----------------------------------------------------------------------------
11 #-----------------------------------------------------------------------------
12
12
13 #-----------------------------------------------------------------------------
13 #-----------------------------------------------------------------------------
14 # Imports
14 # Imports
15 #-----------------------------------------------------------------------------
15 #-----------------------------------------------------------------------------
16
16
17 from .base import ExportersTestsBase
17 from .base import ExportersTestsBase
18 from ..latex import LatexExporter
18 from ..latex import LatexExporter
19 from IPython.testing.decorators import onlyif_cmds_exist
19 from IPython.testing.decorators import onlyif_cmds_exist
20
20
21 #-----------------------------------------------------------------------------
21 #-----------------------------------------------------------------------------
22 # Class
22 # Class
23 #-----------------------------------------------------------------------------
23 #-----------------------------------------------------------------------------
24
24
25 class TestLatexExporter(ExportersTestsBase):
25 class TestLatexExporter(ExportersTestsBase):
26 """Contains test functions for latex.py"""
26 """Contains test functions for latex.py"""
27
27
28 def test_constructor(self):
28 def test_constructor(self):
29 """
29 """
30 Can a LatexExporter be constructed?
30 Can a LatexExporter be constructed?
31 """
31 """
32 LatexExporter()
32 LatexExporter()
33
33
34
34
35 @onlyif_cmds_exist('pandoc')
35 @onlyif_cmds_exist('pandoc')
36 def test_export(self):
36 def test_export(self):
37 """
37 """
38 Can a LatexExporter export something?
38 Can a LatexExporter export something?
39 """
39 """
40 (output, resources) = LatexExporter().from_filename(self._get_notebook())
40 (output, resources) = LatexExporter().from_filename(self._get_notebook())
41 assert len(output) > 0
41 assert len(output) > 0
42
42
43
43
44 def test_export_full(self):
44 def test_export_book(self):
45 """
45 """
46 Can a LatexExporter export using 'full' flavor?
46 Can a LatexExporter export using 'book' flavor?
47 """
47 """
48 (output, resources) = LatexExporter(flavor='full').from_filename(self._get_notebook())
48 (output, resources) = LatexExporter(flavor='book').from_filename(self._get_notebook())
49 assert len(output) > 0
49 assert len(output) > 0
50
50
51
51
52 def test_export_basic(self):
52 def test_export_basic(self):
53 """
53 """
54 Can a LatexExporter export using 'basic' flavor?
54 Can a LatexExporter export using 'basic' flavor?
55 """
55 """
56 (output, resources) = LatexExporter(flavor='basic').from_filename(self._get_notebook())
56 (output, resources) = LatexExporter(flavor='basic').from_filename(self._get_notebook())
57 assert len(output) > 0
57 assert len(output) > 0
58
58
59
59
60 def test_export_reveal(self):
60 def test_export_article(self):
61 """
61 """
62 Can a LatexExporter export using 'reveal' flavor?
62 Can a LatexExporter export using 'article' flavor?
63 """
63 """
64 (output, resources) = LatexExporter(flavor='reveal').from_filename(self._get_notebook())
64 (output, resources) = LatexExporter(flavor='article').from_filename(self._get_notebook())
65 assert len(output) > 0 No newline at end of file
65 assert len(output) > 0
@@ -1,123 +1,135 b''
1 """
1 """
2 Contains tests for the nbconvertapp
2 Contains tests for the nbconvertapp
3 """
3 """
4 #-----------------------------------------------------------------------------
4 #-----------------------------------------------------------------------------
5 #Copyright (c) 2013, the IPython Development Team.
5 #Copyright (c) 2013, the IPython Development Team.
6 #
6 #
7 #Distributed under the terms of the Modified BSD License.
7 #Distributed under the terms of the Modified BSD License.
8 #
8 #
9 #The full license is in the file COPYING.txt, distributed with this software.
9 #The full license is in the file COPYING.txt, distributed with this software.
10 #-----------------------------------------------------------------------------
10 #-----------------------------------------------------------------------------
11
11
12 #-----------------------------------------------------------------------------
12 #-----------------------------------------------------------------------------
13 # Imports
13 # Imports
14 #-----------------------------------------------------------------------------
14 #-----------------------------------------------------------------------------
15
15
16 import os
16 import os
17 from .base import TestsBase
17 from .base import TestsBase
18
18
19 from IPython.utils import py3compat
19 from IPython.utils import py3compat
20
20
21
21
22 #-----------------------------------------------------------------------------
22 #-----------------------------------------------------------------------------
23 # Constants
23 # Constants
24 #-----------------------------------------------------------------------------
24 #-----------------------------------------------------------------------------
25
25
26 # Define ipython commandline name
26 # Define ipython commandline name
27 if py3compat.PY3:
27 if py3compat.PY3:
28 IPYTHON = 'ipython3'
28 IPYTHON = 'ipython3'
29 else:
29 else:
30 IPYTHON = 'ipython'
30 IPYTHON = 'ipython'
31
31
32
32
33 #-----------------------------------------------------------------------------
33 #-----------------------------------------------------------------------------
34 # Classes and functions
34 # Classes and functions
35 #-----------------------------------------------------------------------------
35 #-----------------------------------------------------------------------------
36
36
37 class TestNbConvertApp(TestsBase):
37 class TestNbConvertApp(TestsBase):
38 """Collection of NbConvertApp tests"""
38 """Collection of NbConvertApp tests"""
39
39
40
40
41 def test_notebook_help(self):
41 def test_notebook_help(self):
42 """
42 """
43 Will help show if no notebooks are specified?
43 Will help show if no notebooks are specified?
44 """
44 """
45 with self.create_temp_cwd():
45 with self.create_temp_cwd():
46 assert "see '--help-all'" in self.call([IPYTHON, 'nbconvert'])
46 assert "see '--help-all'" in self.call([IPYTHON, 'nbconvert'])
47
47
48
48
49 def test_glob(self):
49 def test_glob(self):
50 """
50 """
51 Do search patterns work for notebook names?
51 Do search patterns work for notebook names?
52 """
52 """
53 with self.create_temp_cwd(['notebook*.ipynb']):
53 with self.create_temp_cwd(['notebook*.ipynb']):
54 assert not 'error' in self.call([IPYTHON, 'nbconvert',
54 assert not 'error' in self.call([IPYTHON, 'nbconvert',
55 '--format="python"', '--notebooks=["*.ipynb"]']).lower()
55 '--to="python"', '--notebooks=["*.ipynb"]']).lower()
56 assert os.path.isfile('notebook1.py')
56 assert os.path.isfile('notebook1.py')
57 assert os.path.isfile('notebook2.py')
57 assert os.path.isfile('notebook2.py')
58
58
59
59
60 def test_glob_subdir(self):
60 def test_glob_subdir(self):
61 """
61 """
62 Do search patterns work for subdirectory notebook names?
62 Do search patterns work for subdirectory notebook names?
63 """
63 """
64 with self.create_temp_cwd() as cwd:
64 with self.create_temp_cwd() as cwd:
65 self.copy_files_to(['notebook*.ipynb'], 'subdir/')
65 self.copy_files_to(['notebook*.ipynb'], 'subdir/')
66 assert not 'error' in self.call([IPYTHON, 'nbconvert', '--format="python"',
66 assert not 'error' in self.call([IPYTHON, 'nbconvert', '--to="python"',
67 '--notebooks=["%s"]' % os.path.join('subdir', '*.ipynb')]).lower()
67 '--notebooks=["%s"]' % os.path.join('subdir', '*.ipynb')]).lower()
68 assert os.path.isfile('notebook1.py')
68 assert os.path.isfile('notebook1.py')
69 assert os.path.isfile('notebook2.py')
69 assert os.path.isfile('notebook2.py')
70
70
71
71
72 def test_explicit(self):
72 def test_explicit(self):
73 """
73 """
74 Do explicit notebook names work?
74 Do explicit notebook names work?
75 """
75 """
76 with self.create_temp_cwd(['notebook*.ipynb']):
76 with self.create_temp_cwd(['notebook*.ipynb']):
77 assert not 'error' in self.call([IPYTHON, 'nbconvert', '--format="python"',
77 assert not 'error' in self.call([IPYTHON, 'nbconvert', '--to="python"',
78 '--notebooks=["notebook2.ipynb"]']).lower()
78 '--notebooks=["notebook2.ipynb"]']).lower()
79 assert not os.path.isfile('notebook1.py')
79 assert not os.path.isfile('notebook1.py')
80 assert os.path.isfile('notebook2.py')
80 assert os.path.isfile('notebook2.py')
81
81
82
82
83 def test_flavor(self):
84 """
85 Do explicit notebook names work?
86 """
87 with self.create_temp_cwd(['notebook*.ipynb']):
88 assert not 'error' in self.call([IPYTHON, 'nbconvert', '--to="html"',
89 '--notebooks=["notebook2.ipynb"]', '--flavor="reveal"']).lower()
90 assert os.path.isfile('notebook2.html')
91 with open('notebook2.html') as f:
92 assert '/reveal.css' in f.read()
93
94
83 def test_glob_explicit(self):
95 def test_glob_explicit(self):
84 """
96 """
85 Can a search pattern be used along with matching explicit notebook names?
97 Can a search pattern be used along with matching explicit notebook names?
86 """
98 """
87 with self.create_temp_cwd(['notebook*.ipynb']):
99 with self.create_temp_cwd(['notebook*.ipynb']):
88 assert not 'error' in self.call([IPYTHON, 'nbconvert', '--format="python"',
100 assert not 'error' in self.call([IPYTHON, 'nbconvert', '--to="python"',
89 '--notebooks=["*.ipynb", "notebook1.ipynb", "notebook2.ipynb"]']).lower()
101 '--notebooks=["*.ipynb", "notebook1.ipynb", "notebook2.ipynb"]']).lower()
90 assert os.path.isfile('notebook1.py')
102 assert os.path.isfile('notebook1.py')
91 assert os.path.isfile('notebook2.py')
103 assert os.path.isfile('notebook2.py')
92
104
93
105
94 def test_explicit_glob(self):
106 def test_explicit_glob(self):
95 """
107 """
96 Can explicit notebook names be used and then a matching search pattern?
108 Can explicit notebook names be used and then a matching search pattern?
97 """
109 """
98 with self.create_temp_cwd(['notebook*.ipynb']):
110 with self.create_temp_cwd(['notebook*.ipynb']):
99 assert not 'error' in self.call([IPYTHON, 'nbconvert', '--format="python"',
111 assert not 'error' in self.call([IPYTHON, 'nbconvert', '--to="python"',
100 '--notebooks=["notebook1.ipynb", "notebook2.ipynb", "*.ipynb"]']).lower()
112 '--notebooks=["notebook1.ipynb", "notebook2.ipynb", "*.ipynb"]']).lower()
101 assert os.path.isfile('notebook1.py')
113 assert os.path.isfile('notebook1.py')
102 assert os.path.isfile('notebook2.py')
114 assert os.path.isfile('notebook2.py')
103
115
104
116
105 def test_default_config(self):
117 def test_default_config(self):
106 """
118 """
107 Does the default config work?
119 Does the default config work?
108 """
120 """
109 with self.create_temp_cwd(['notebook*.ipynb', 'ipython_nbconvert_config.py']):
121 with self.create_temp_cwd(['notebook*.ipynb', 'ipython_nbconvert_config.py']):
110 assert not 'error' in self.call([IPYTHON, 'nbconvert']).lower()
122 assert not 'error' in self.call([IPYTHON, 'nbconvert']).lower()
111 assert os.path.isfile('notebook1.py')
123 assert os.path.isfile('notebook1.py')
112 assert not os.path.isfile('notebook2.py')
124 assert not os.path.isfile('notebook2.py')
113
125
114
126
115 def test_override_config(self):
127 def test_override_config(self):
116 """
128 """
117 Can the default config be overriden?
129 Can the default config be overriden?
118 """
130 """
119 with self.create_temp_cwd(['notebook*.ipynb', 'ipython_nbconvert_config.py',
131 with self.create_temp_cwd(['notebook*.ipynb', 'ipython_nbconvert_config.py',
120 'override.py']):
132 'override.py']):
121 assert not 'error' in self.call([IPYTHON, 'nbconvert', '--config="override.py"']).lower()
133 assert not 'error' in self.call([IPYTHON, 'nbconvert', '--config="override.py"']).lower()
122 assert not os.path.isfile('notebook1.py')
134 assert not os.path.isfile('notebook1.py')
123 assert os.path.isfile('notebook2.py')
135 assert os.path.isfile('notebook2.py')
General Comments 0
You need to be logged in to leave comments. Login now