##// END OF EJS Templates
Fixed double single apostrophe
Jonathan Frederic -
Show More
@@ -0,0 +1,201 b''
1 """
2 Contains tests for the nbconvertapp
3 """
4 #-----------------------------------------------------------------------------
5 #Copyright (c) 2013, the IPython Development Team.
6 #
7 #Distributed under the terms of the Modified BSD License.
8 #
9 #The full license is in the file COPYING.txt, distributed with this software.
10 #-----------------------------------------------------------------------------
11
12 #-----------------------------------------------------------------------------
13 # Imports
14 #-----------------------------------------------------------------------------
15
16 import os
17 from .base import TestsBase
18
19 from IPython.testing import decorators as dec
20
21
22 #-----------------------------------------------------------------------------
23 # Constants
24 #-----------------------------------------------------------------------------
25
26
27 #-----------------------------------------------------------------------------
28 # Classes and functions
29 #-----------------------------------------------------------------------------
30
31 class TestNbConvertApp(TestsBase):
32 """Collection of NbConvertApp tests"""
33
34
35 def test_notebook_help(self):
36 """
37 Will help show if no notebooks are specified?
38 """
39 with self.create_temp_cwd():
40 <<<<<<< HEAD
41 out, err = self.call('nbconvert', raise_on_error=False)
42 assert "see '--help-all'" in out
43 =======
44 assert "see '--help-all'" in self.call([IPYTHON, 'nbconvert',
45 '--NbConvertApp.log_level="WARN"'])
46 >>>>>>> Silence INFO logging in test output
47
48
49 def test_glob(self):
50 """
51 Do search patterns work for notebook names?
52 """
53 with self.create_temp_cwd(['notebook*.ipynb']):
54 <<<<<<< HEAD
55 self.call('nbconvert --to="python" --notebooks=\'["*.ipynb"]\'')
56 =======
57 assert not 'error' in self.call([IPYTHON, 'nbconvert',
58 '--to="python"', '--notebooks=["*.ipynb"]',
59 '--NbConvertApp.log_level="WARN"']).lower()
60 >>>>>>> Silence INFO logging in test output
61 assert os.path.isfile('notebook1.py')
62 assert os.path.isfile('notebook2.py')
63
64
65 def test_glob_subdir(self):
66 """
67 Do search patterns work for subdirectory notebook names?
68 """
69 with self.create_temp_cwd():
70 self.copy_files_to(['notebook*.ipynb'], 'subdir/')
71 <<<<<<< HEAD
72 self.call('nbconvert --to="python" --notebooks='
73 '\'["%s"]\'' % os.path.join('subdir', '*.ipynb'))
74 =======
75 assert not 'error' in self.call([IPYTHON, 'nbconvert', '--to="python"',
76 '--notebooks=["%s"]' % os.path.join('subdir', '*.ipynb'),
77 '--NbConvertApp.log_level="WARN"']).lower()
78 >>>>>>> Silence INFO logging in test output
79 assert os.path.isfile('notebook1.py')
80 assert os.path.isfile('notebook2.py')
81
82
83 def test_explicit(self):
84 """
85 Do explicit notebook names work?
86 """
87 with self.create_temp_cwd(['notebook*.ipynb']):
88 <<<<<<< HEAD
89 self.call('nbconvert --to="python" --notebooks='
90 '\'["notebook2.ipynb"]\'')
91 =======
92 assert not 'error' in self.call([IPYTHON, 'nbconvert', '--to="python"',
93 '--notebooks=["notebook2.ipynb"]',
94 '--NbConvertApp.log_level="WARN"']).lower()
95 >>>>>>> Silence INFO logging in test output
96 assert not os.path.isfile('notebook1.py')
97 assert os.path.isfile('notebook2.py')
98
99
100 @dec.onlyif_cmds_exist('pdflatex')
101 @dec.onlyif_cmds_exist('pandoc')
102 def test_post_processor(self):
103 """
104 Do post processors work?
105 """
106 with self.create_temp_cwd(['notebook1.ipynb']):
107 <<<<<<< HEAD
108 self.call('nbconvert --to="latex" notebook1'
109 ' --post="PDF" --PDFPostProcessor.verbose=True')
110 =======
111 assert not 'error' in self.call([IPYTHON, 'nbconvert', '--to="latex"',
112 'notebook1', '--post="PDF"', '--PDFPostProcessor.verbose=True',
113 '--NbConvertApp.log_level="WARN"']).lower()
114 >>>>>>> Silence INFO logging in test output
115 assert os.path.isfile('notebook1.tex')
116 assert os.path.isfile('notebook1.pdf')
117
118
119 @dec.onlyif_cmds_exist('pandoc')
120 def test_template(self):
121 """
122 Do export templates work?
123 """
124 with self.create_temp_cwd(['notebook2.ipynb']):
125 <<<<<<< HEAD
126 self.call('nbconvert --to=slides --notebooks='
127 '\'["notebook2.ipynb"]\' --template=reveal')
128 =======
129 assert not 'error' in self.call([IPYTHON, 'nbconvert', '--to=slides',
130 '--notebooks=["notebook2.ipynb"]', '--template=reveal',
131 '--NbConvertApp.log_level="WARN"']).lower()
132 >>>>>>> Silence INFO logging in test output
133 assert os.path.isfile('notebook2.slides.html')
134 with open('notebook2.slides.html') as f:
135 assert '/reveal.css' in f.read()
136
137
138 def test_glob_explicit(self):
139 """
140 Can a search pattern be used along with matching explicit notebook names?
141 """
142 with self.create_temp_cwd(['notebook*.ipynb']):
143 <<<<<<< HEAD
144 self.call('nbconvert --to="python" --notebooks='
145 '\'["*.ipynb","notebook1.ipynb","notebook2.ipynb"]\'')
146 =======
147 assert not 'error' in self.call([IPYTHON, 'nbconvert', '--to="python"',
148 '--notebooks=["*.ipynb", "notebook1.ipynb", "notebook2.ipynb"]',
149 '--NbConvertApp.log_level="WARN"']).lower()
150 >>>>>>> Silence INFO logging in test output
151 assert os.path.isfile('notebook1.py')
152 assert os.path.isfile('notebook2.py')
153
154
155 def test_explicit_glob(self):
156 """
157 Can explicit notebook names be used and then a matching search pattern?
158 """
159 with self.create_temp_cwd(['notebook*.ipynb']):
160 <<<<<<< HEAD
161 self.call('nbconvert --to="python" --notebooks='
162 '\'["notebook1.ipynb","notebook2.ipynb","*.ipynb"]\'')
163 =======
164 assert not 'error' in self.call([IPYTHON, 'nbconvert', '--to="python"',
165 '--notebooks=["notebook1.ipynb", "notebook2.ipynb", "*.ipynb"]',
166 '--NbConvertApp.log_level="WARN"']).lower()
167 >>>>>>> Silence INFO logging in test output
168 assert os.path.isfile('notebook1.py')
169 assert os.path.isfile('notebook2.py')
170
171
172 def test_default_config(self):
173 """
174 Does the default config work?
175 """
176 with self.create_temp_cwd(['notebook*.ipynb', 'ipython_nbconvert_config.py']):
177 <<<<<<< HEAD
178 self.call('nbconvert')
179 =======
180 assert not 'error' in self.call([IPYTHON, 'nbconvert',
181 '--NbConvertApp.log_level="WARN"']).lower()
182 >>>>>>> Silence INFO logging in test output
183 assert os.path.isfile('notebook1.py')
184 assert not os.path.isfile('notebook2.py')
185
186
187 def test_override_config(self):
188 """
189 Can the default config be overriden?
190 """
191 with self.create_temp_cwd(['notebook*.ipynb',
192 'ipython_nbconvert_config.py',
193 'override.py']):
194 <<<<<<< HEAD
195 self.call('nbconvert --config="override.py"')
196 =======
197 assert not 'error' in self.call([IPYTHON, 'nbconvert', '--config="override.py"',
198 '--NbConvertApp.log_level="WARN"']).lower()
199 >>>>>>> Silence INFO logging in test output
200 assert not os.path.isfile('notebook1.py')
201 assert os.path.isfile('notebook2.py')
@@ -1,144 +1,144 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.testing import decorators as dec
19 from IPython.testing import decorators as dec
20
20
21
21
22 #-----------------------------------------------------------------------------
22 #-----------------------------------------------------------------------------
23 # Constants
23 # Constants
24 #-----------------------------------------------------------------------------
24 #-----------------------------------------------------------------------------
25
25
26
26
27 #-----------------------------------------------------------------------------
27 #-----------------------------------------------------------------------------
28 # Classes and functions
28 # Classes and functions
29 #-----------------------------------------------------------------------------
29 #-----------------------------------------------------------------------------
30
30
31 class TestNbConvertApp(TestsBase):
31 class TestNbConvertApp(TestsBase):
32 """Collection of NbConvertApp tests"""
32 """Collection of NbConvertApp tests"""
33
33
34
34
35 def test_notebook_help(self):
35 def test_notebook_help(self):
36 """
36 """
37 Will help show if no notebooks are specified?
37 Will help show if no notebooks are specified?
38 """
38 """
39 with self.create_temp_cwd():
39 with self.create_temp_cwd():
40 out, err = self.call('nbconvert --NbConvertApp.log_level="WARN"'', raise_on_error=False)
40 out, err = self.call('nbconvert --NbConvertApp.log_level="WARN"', raise_on_error=False)
41 assert "see '--help-all'" in out
41 assert "see '--help-all'" in out
42
42
43
43
44 def test_glob(self):
44 def test_glob(self):
45 """
45 """
46 Do search patterns work for notebook names?
46 Do search patterns work for notebook names?
47 """
47 """
48 with self.create_temp_cwd(['notebook*.ipynb']):
48 with self.create_temp_cwd(['notebook*.ipynb']):
49 self.call('nbconvert --to="python" --notebooks=\'["*.ipynb"]\' --NbConvertApp.log_level="WARN"'')
49 self.call('nbconvert --to="python" --notebooks=\'["*.ipynb"]\' --NbConvertApp.log_level="WARN"')
50 assert os.path.isfile('notebook1.py')
50 assert os.path.isfile('notebook1.py')
51 assert os.path.isfile('notebook2.py')
51 assert os.path.isfile('notebook2.py')
52
52
53
53
54 def test_glob_subdir(self):
54 def test_glob_subdir(self):
55 """
55 """
56 Do search patterns work for subdirectory notebook names?
56 Do search patterns work for subdirectory notebook names?
57 """
57 """
58 with self.create_temp_cwd():
58 with self.create_temp_cwd():
59 self.copy_files_to(['notebook*.ipynb'], 'subdir/')
59 self.copy_files_to(['notebook*.ipynb'], 'subdir/')
60 self.call('nbconvert --to="python" --NbConvertApp.log_level="WARN"' --notebooks='
60 self.call('nbconvert --to="python" --NbConvertApp.log_level="WARN" --notebooks='
61 '\'["%s"]\'' % os.path.join('subdir', '*.ipynb'))
61 '\'["%s"]\'' % os.path.join('subdir', '*.ipynb'))
62 assert os.path.isfile('notebook1.py')
62 assert os.path.isfile('notebook1.py')
63 assert os.path.isfile('notebook2.py')
63 assert os.path.isfile('notebook2.py')
64
64
65
65
66 def test_explicit(self):
66 def test_explicit(self):
67 """
67 """
68 Do explicit notebook names work?
68 Do explicit notebook names work?
69 """
69 """
70 with self.create_temp_cwd(['notebook*.ipynb']):
70 with self.create_temp_cwd(['notebook*.ipynb']):
71 self.call('nbconvert --NbConvertApp.log_level="WARN"' --to="python" --notebooks='
71 self.call('nbconvert --NbConvertApp.log_level="WARN" --to="python" --notebooks='
72 '\'["notebook2.ipynb"]\'')
72 '\'["notebook2.ipynb"]\'')
73 assert not os.path.isfile('notebook1.py')
73 assert not os.path.isfile('notebook1.py')
74 assert os.path.isfile('notebook2.py')
74 assert os.path.isfile('notebook2.py')
75
75
76
76
77 @dec.onlyif_cmds_exist('pdflatex')
77 @dec.onlyif_cmds_exist('pdflatex')
78 @dec.onlyif_cmds_exist('pandoc')
78 @dec.onlyif_cmds_exist('pandoc')
79 def test_post_processor(self):
79 def test_post_processor(self):
80 """
80 """
81 Do post processors work?
81 Do post processors work?
82 """
82 """
83 with self.create_temp_cwd(['notebook1.ipynb']):
83 with self.create_temp_cwd(['notebook1.ipynb']):
84 self.call('nbconvert --NbConvertApp.log_level="WARN"' --to="latex" notebook1'
84 self.call('nbconvert --NbConvertApp.log_level="WARN" --to="latex" notebook1'
85 ' --post="PDF" --PDFPostProcessor.verbose=True')
85 ' --post="PDF" --PDFPostProcessor.verbose=True')
86 assert os.path.isfile('notebook1.tex')
86 assert os.path.isfile('notebook1.tex')
87 assert os.path.isfile('notebook1.pdf')
87 assert os.path.isfile('notebook1.pdf')
88
88
89
89
90 @dec.onlyif_cmds_exist('pandoc')
90 @dec.onlyif_cmds_exist('pandoc')
91 def test_template(self):
91 def test_template(self):
92 """
92 """
93 Do export templates work?
93 Do export templates work?
94 """
94 """
95 with self.create_temp_cwd(['notebook2.ipynb']):
95 with self.create_temp_cwd(['notebook2.ipynb']):
96 self.call('nbconvert --NbConvertApp.log_level="WARN"' --to=slides --notebooks='
96 self.call('nbconvert --NbConvertApp.log_level="WARN" --to=slides --notebooks='
97 '\'["notebook2.ipynb"]\' --template=reveal')
97 '\'["notebook2.ipynb"]\' --template=reveal')
98 assert os.path.isfile('notebook2.slides.html')
98 assert os.path.isfile('notebook2.slides.html')
99 with open('notebook2.slides.html') as f:
99 with open('notebook2.slides.html') as f:
100 assert '/reveal.css' in f.read()
100 assert '/reveal.css' in f.read()
101
101
102
102
103 def test_glob_explicit(self):
103 def test_glob_explicit(self):
104 """
104 """
105 Can a search pattern be used along with matching explicit notebook names?
105 Can a search pattern be used along with matching explicit notebook names?
106 """
106 """
107 with self.create_temp_cwd(['notebook*.ipynb']):
107 with self.create_temp_cwd(['notebook*.ipynb']):
108 self.call('nbconvert --NbConvertApp.log_level="WARN"' --to="python" --notebooks='
108 self.call('nbconvert --NbConvertApp.log_level="WARN" --to="python" --notebooks='
109 '\'["*.ipynb","notebook1.ipynb","notebook2.ipynb"]\'')
109 '\'["*.ipynb","notebook1.ipynb","notebook2.ipynb"]\'')
110 assert os.path.isfile('notebook1.py')
110 assert os.path.isfile('notebook1.py')
111 assert os.path.isfile('notebook2.py')
111 assert os.path.isfile('notebook2.py')
112
112
113
113
114 def test_explicit_glob(self):
114 def test_explicit_glob(self):
115 """
115 """
116 Can explicit notebook names be used and then a matching search pattern?
116 Can explicit notebook names be used and then a matching search pattern?
117 """
117 """
118 with self.create_temp_cwd(['notebook*.ipynb']):
118 with self.create_temp_cwd(['notebook*.ipynb']):
119 self.call('nbconvert --NbConvertApp.log_level="WARN"' --to="python" --notebooks='
119 self.call('nbconvert --NbConvertApp.log_level="WARN" --to="python" --notebooks='
120 '\'["notebook1.ipynb","notebook2.ipynb","*.ipynb"]\'')
120 '\'["notebook1.ipynb","notebook2.ipynb","*.ipynb"]\'')
121 assert os.path.isfile('notebook1.py')
121 assert os.path.isfile('notebook1.py')
122 assert os.path.isfile('notebook2.py')
122 assert os.path.isfile('notebook2.py')
123
123
124
124
125 def test_default_config(self):
125 def test_default_config(self):
126 """
126 """
127 Does the default config work?
127 Does the default config work?
128 """
128 """
129 with self.create_temp_cwd(['notebook*.ipynb', 'ipython_nbconvert_config.py']):
129 with self.create_temp_cwd(['notebook*.ipynb', 'ipython_nbconvert_config.py']):
130 self.call('nbconvert --NbConvertApp.log_level="WARN"'')
130 self.call('nbconvert --NbConvertApp.log_level="WARN"')
131 assert os.path.isfile('notebook1.py')
131 assert os.path.isfile('notebook1.py')
132 assert not os.path.isfile('notebook2.py')
132 assert not os.path.isfile('notebook2.py')
133
133
134
134
135 def test_override_config(self):
135 def test_override_config(self):
136 """
136 """
137 Can the default config be overriden?
137 Can the default config be overriden?
138 """
138 """
139 with self.create_temp_cwd(['notebook*.ipynb',
139 with self.create_temp_cwd(['notebook*.ipynb',
140 'ipython_nbconvert_config.py',
140 'ipython_nbconvert_config.py',
141 'override.py']):
141 'override.py']):
142 self.call('nbconvert --NbConvertApp.log_level="WARN"' --config="override.py"')
142 self.call('nbconvert --NbConvertApp.log_level="WARN" --config="override.py"')
143 assert not os.path.isfile('notebook1.py')
143 assert not os.path.isfile('notebook1.py')
144 assert os.path.isfile('notebook2.py')
144 assert os.path.isfile('notebook2.py')
General Comments 0
You need to be logged in to leave comments. Login now