Show More
@@ -59,7 +59,6 b' nbconvert_aliases.update(base_aliases)' | |||||
59 | nbconvert_aliases.update({ |
|
59 | nbconvert_aliases.update({ | |
60 | 'to' : 'NbConvertApp.export_format', |
|
60 | 'to' : 'NbConvertApp.export_format', | |
61 | 'template' : 'Exporter.template_file', |
|
61 | 'template' : 'Exporter.template_file', | |
62 | 'notebooks' : 'NbConvertApp.notebooks', |
|
|||
63 | 'writer' : 'NbConvertApp.writer_class', |
|
62 | 'writer' : 'NbConvertApp.writer_class', | |
64 | 'post': 'NbConvertApp.post_processor_class', |
|
63 | 'post': 'NbConvertApp.post_processor_class', | |
65 | 'output': 'NbConvertApp.output_base' |
|
64 | 'output': 'NbConvertApp.output_base' |
@@ -136,8 +136,20 b' class TestsBase(ParametricTestCase):' | |||||
136 | return path |
|
136 | return path | |
137 |
|
137 | |||
138 |
|
138 | |||
139 |
def call(self, parameters, |
|
139 | def call(self, parameters, ignore_return_code=False): | |
|
140 | """ | |||
|
141 | Execute a, IPython shell command, listening for both Errors and non-zero | |||
|
142 | return codes. | |||
|
143 | ||||
|
144 | PARAMETERS: | |||
|
145 | ----------- | |||
|
146 | parameters : str | |||
|
147 | List of parameters to pass to IPython. | |||
|
148 | ignore_return_code : optional bool (default False) | |||
|
149 | Throw an OSError if the return code | |||
|
150 | """ | |||
|
151 | ||||
140 | stdout, stderr, retcode = get_output_error_code(ipy_cmd + parameters) |
|
152 | stdout, stderr, retcode = get_output_error_code(ipy_cmd + parameters) | |
141 |
if retcode |
|
153 | if not (retcode == 0 or ignore_return_code): | |
142 | raise OSError(stderr) |
|
154 | raise OSError(stderr) | |
143 | return stdout, stderr |
|
155 | return stdout, stderr |
@@ -39,7 +39,7 b' class TestNbConvertApp(TestsBase):' | |||||
39 | Will help show if no notebooks are specified? |
|
39 | Will help show if no notebooks are specified? | |
40 | """ |
|
40 | """ | |
41 | with self.create_temp_cwd(): |
|
41 | with self.create_temp_cwd(): | |
42 |
out, err = self.call('nbconvert --log-level |
|
42 | out, err = self.call('nbconvert --log-level 0', ignore_return_code=True) | |
43 | assert "see '--help-all'" in out |
|
43 | assert "see '--help-all'" in out | |
44 |
|
44 | |||
45 |
|
45 | |||
@@ -48,7 +48,7 b' class TestNbConvertApp(TestsBase):' | |||||
48 | Do search patterns work for notebook names? |
|
48 | Do search patterns work for notebook names? | |
49 | """ |
|
49 | """ | |
50 | with self.create_temp_cwd(['notebook*.ipynb']): |
|
50 | with self.create_temp_cwd(['notebook*.ipynb']): | |
51 |
self.call('nbconvert --to |
|
51 | self.call('nbconvert --to python *.ipynb --log-level 0') | |
52 | assert os.path.isfile('notebook1.py') |
|
52 | assert os.path.isfile('notebook1.py') | |
53 | assert os.path.isfile('notebook2.py') |
|
53 | assert os.path.isfile('notebook2.py') | |
54 |
|
54 | |||
@@ -59,8 +59,8 b' class TestNbConvertApp(TestsBase):' | |||||
59 | """ |
|
59 | """ | |
60 | with self.create_temp_cwd(): |
|
60 | with self.create_temp_cwd(): | |
61 | self.copy_files_to(['notebook*.ipynb'], 'subdir/') |
|
61 | self.copy_files_to(['notebook*.ipynb'], 'subdir/') | |
62 |
self.call('nbconvert --to |
|
62 | self.call('nbconvert --to python --log-level 0 ' + | |
63 |
|
|
63 | os.path.join('subdir', '*.ipynb')) | |
64 | assert os.path.isfile('notebook1.py') |
|
64 | assert os.path.isfile('notebook1.py') | |
65 | assert os.path.isfile('notebook2.py') |
|
65 | assert os.path.isfile('notebook2.py') | |
66 |
|
66 | |||
@@ -70,8 +70,7 b' class TestNbConvertApp(TestsBase):' | |||||
70 | Do explicit notebook names work? |
|
70 | Do explicit notebook names work? | |
71 | """ |
|
71 | """ | |
72 | with self.create_temp_cwd(['notebook*.ipynb']): |
|
72 | with self.create_temp_cwd(['notebook*.ipynb']): | |
73 |
self.call('nbconvert --log-level |
|
73 | self.call('nbconvert --log-level 0 --to python notebook2') | |
74 | '\'["notebook2.ipynb"]\'') |
|
|||
75 | assert not os.path.isfile('notebook1.py') |
|
74 | assert not os.path.isfile('notebook1.py') | |
76 | assert os.path.isfile('notebook2.py') |
|
75 | assert os.path.isfile('notebook2.py') | |
77 |
|
76 | |||
@@ -84,8 +83,9 b' class TestNbConvertApp(TestsBase):' | |||||
84 | """ |
|
83 | """ | |
85 | with self.create_temp_cwd(['notebook2.ipynb']): |
|
84 | with self.create_temp_cwd(['notebook2.ipynb']): | |
86 | os.rename('notebook2.ipynb', 'notebook with spaces.ipynb') |
|
85 | os.rename('notebook2.ipynb', 'notebook with spaces.ipynb') | |
87 |
o,e = self.call('nbconvert --log-level |
|
86 | o,e = self.call('nbconvert --log-level 0 --to latex ' | |
88 | ' --post="PDF" --PDFPostProcessor.verbose=True') |
|
87 | '"notebook with spaces" --post PDF ' | |
|
88 | '--PDFPostProcessor.verbose=True') | |||
89 | assert os.path.isfile('notebook with spaces.tex') |
|
89 | assert os.path.isfile('notebook with spaces.tex') | |
90 | assert os.path.isdir('notebook with spaces_files') |
|
90 | assert os.path.isdir('notebook with spaces_files') | |
91 | assert os.path.isfile('notebook with spaces.pdf') |
|
91 | assert os.path.isfile('notebook with spaces.pdf') | |
@@ -97,8 +97,8 b' class TestNbConvertApp(TestsBase):' | |||||
97 | Do post processors work? |
|
97 | Do post processors work? | |
98 | """ |
|
98 | """ | |
99 | with self.create_temp_cwd(['notebook1.ipynb']): |
|
99 | with self.create_temp_cwd(['notebook1.ipynb']): | |
100 |
self.call('nbconvert --log-level |
|
100 | self.call('nbconvert --log-level 0 --to latex notebook1 ' | |
101 |
' |
|
101 | '--post PDF --PDFPostProcessor.verbose=True') | |
102 | assert os.path.isfile('notebook1.tex') |
|
102 | assert os.path.isfile('notebook1.tex') | |
103 | assert os.path.isfile('notebook1.pdf') |
|
103 | assert os.path.isfile('notebook1.pdf') | |
104 |
|
104 | |||
@@ -109,8 +109,8 b' class TestNbConvertApp(TestsBase):' | |||||
109 | Do export templates work? |
|
109 | Do export templates work? | |
110 | """ |
|
110 | """ | |
111 | with self.create_temp_cwd(['notebook2.ipynb']): |
|
111 | with self.create_temp_cwd(['notebook2.ipynb']): | |
112 |
self.call('nbconvert --log-level |
|
112 | self.call('nbconvert --log-level 0 --to slides ' | |
113 |
' |
|
113 | 'notebook2.ipynb --template reveal') | |
114 | assert os.path.isfile('notebook2.slides.html') |
|
114 | assert os.path.isfile('notebook2.slides.html') | |
115 | with open('notebook2.slides.html') as f: |
|
115 | with open('notebook2.slides.html') as f: | |
116 | assert '/reveal.css' in f.read() |
|
116 | assert '/reveal.css' in f.read() | |
@@ -121,8 +121,8 b' class TestNbConvertApp(TestsBase):' | |||||
121 | Can a search pattern be used along with matching explicit notebook names? |
|
121 | Can a search pattern be used along with matching explicit notebook names? | |
122 | """ |
|
122 | """ | |
123 | with self.create_temp_cwd(['notebook*.ipynb']): |
|
123 | with self.create_temp_cwd(['notebook*.ipynb']): | |
124 |
self.call('nbconvert --log-level |
|
124 | self.call('nbconvert --log-level 0 --to python ' | |
125 |
' |
|
125 | '*.ipynb notebook1.ipynb notebook2.ipynb') | |
126 | assert os.path.isfile('notebook1.py') |
|
126 | assert os.path.isfile('notebook1.py') | |
127 | assert os.path.isfile('notebook2.py') |
|
127 | assert os.path.isfile('notebook2.py') | |
128 |
|
128 | |||
@@ -132,8 +132,8 b' class TestNbConvertApp(TestsBase):' | |||||
132 | Can explicit notebook names be used and then a matching search pattern? |
|
132 | Can explicit notebook names be used and then a matching search pattern? | |
133 | """ |
|
133 | """ | |
134 | with self.create_temp_cwd(['notebook*.ipynb']): |
|
134 | with self.create_temp_cwd(['notebook*.ipynb']): | |
135 |
self.call('nbconvert --log-level |
|
135 | self.call('nbconvert --log-level 0 --to=python ' | |
136 |
' |
|
136 | 'notebook1.ipynb notebook2.ipynb *.ipynb') | |
137 | assert os.path.isfile('notebook1.py') |
|
137 | assert os.path.isfile('notebook1.py') | |
138 | assert os.path.isfile('notebook2.py') |
|
138 | assert os.path.isfile('notebook2.py') | |
139 |
|
139 | |||
@@ -143,7 +143,7 b' class TestNbConvertApp(TestsBase):' | |||||
143 | Does the default config work? |
|
143 | Does the default config work? | |
144 | """ |
|
144 | """ | |
145 | with self.create_temp_cwd(['notebook*.ipynb', 'ipython_nbconvert_config.py']): |
|
145 | with self.create_temp_cwd(['notebook*.ipynb', 'ipython_nbconvert_config.py']): | |
146 |
self.call('nbconvert --log-level |
|
146 | self.call('nbconvert --log-level 0') | |
147 | assert os.path.isfile('notebook1.py') |
|
147 | assert os.path.isfile('notebook1.py') | |
148 | assert not os.path.isfile('notebook2.py') |
|
148 | assert not os.path.isfile('notebook2.py') | |
149 |
|
149 | |||
@@ -155,6 +155,6 b' class TestNbConvertApp(TestsBase):' | |||||
155 | with self.create_temp_cwd(['notebook*.ipynb', |
|
155 | with self.create_temp_cwd(['notebook*.ipynb', | |
156 | 'ipython_nbconvert_config.py', |
|
156 | 'ipython_nbconvert_config.py', | |
157 | 'override.py']): |
|
157 | 'override.py']): | |
158 |
self.call('nbconvert --log-level |
|
158 | self.call('nbconvert --log-level 0 --config="override.py"') | |
159 | assert not os.path.isfile('notebook1.py') |
|
159 | assert not os.path.isfile('notebook1.py') | |
160 | assert os.path.isfile('notebook2.py') |
|
160 | assert os.path.isfile('notebook2.py') |
General Comments 0
You need to be logged in to leave comments.
Login now