Show More
@@ -13,13 +13,16 b' Contains base test class for nbconvert' | |||||
13 | # Imports |
|
13 | # Imports | |
14 | #----------------------------------------------------------------------------- |
|
14 | #----------------------------------------------------------------------------- | |
15 |
|
15 | |||
|
16 | import io | |||
16 | import os |
|
17 | import os | |
17 | import glob |
|
18 | import glob | |
18 | import shutil |
|
19 | import shutil | |
19 | import unittest |
|
20 | import unittest | |
20 |
|
21 | |||
21 | import IPython |
|
22 | import IPython | |
|
23 | from IPython.nbformat import current | |||
22 | from IPython.utils.tempdir import TemporaryWorkingDirectory |
|
24 | from IPython.utils.tempdir import TemporaryWorkingDirectory | |
|
25 | from IPython.utils.path import get_ipython_package_dir | |||
23 | from IPython.utils.process import get_output_error_code |
|
26 | from IPython.utils.process import get_output_error_code | |
24 | from IPython.testing.tools import get_ipython_cmd |
|
27 | from IPython.testing.tools import get_ipython_cmd | |
25 |
|
28 | |||
@@ -110,6 +113,12 b' class TestsBase(unittest.TestCase):' | |||||
110 |
|
113 | |||
111 | #Return directory handler |
|
114 | #Return directory handler | |
112 | return temp_dir |
|
115 | return temp_dir | |
|
116 | ||||
|
117 | def create_empty_notebook(self, path): | |||
|
118 | nb = current.new_notebook() | |||
|
119 | nb.worksheets.append(current.new_worksheet()) | |||
|
120 | with io.open(path, 'w', encoding='utf-8') as f: | |||
|
121 | current.write(nb, f, 'json') | |||
113 |
|
122 | |||
114 |
|
123 | |||
115 | def copy_files_to(self, copy_filenames, dest='.'): |
|
124 | def copy_files_to(self, copy_filenames, dest='.'): | |
@@ -130,7 +139,7 b' class TestsBase(unittest.TestCase):' | |||||
130 |
|
139 | |||
131 | #Build a path using the IPython directory and the relative path we just |
|
140 | #Build a path using the IPython directory and the relative path we just | |
132 | #found. |
|
141 | #found. | |
133 |
path = |
|
142 | path = get_ipython_package_dir() | |
134 | for name in names: |
|
143 | for name in names: | |
135 | path = os.path.join(path, name) |
|
144 | path = os.path.join(path, name) | |
136 | return path |
|
145 | return path |
@@ -189,7 +189,8 b' class TestNbConvertApp(TestsBase):' | |||||
189 | """ |
|
189 | """ | |
190 | Can notebook names include accents? |
|
190 | Can notebook names include accents? | |
191 | """ |
|
191 | """ | |
192 |
with self.create_temp_cwd( |
|
192 | with self.create_temp_cwd(): | |
|
193 | self.create_empty_notebook(u'nb1_análisis.ipynb') | |||
193 | self.call('nbconvert --log-level 0 --to python nb1_*') |
|
194 | self.call('nbconvert --log-level 0 --to python nb1_*') | |
194 | assert os.path.isfile(u'nb1_análisis.py') |
|
195 | assert os.path.isfile(u'nb1_análisis.py') | |
195 |
|
196 | |||
@@ -199,7 +200,8 b' class TestNbConvertApp(TestsBase):' | |||||
199 | """ |
|
200 | """ | |
200 | Generate PDFs if notebooks have an accent in their name? |
|
201 | Generate PDFs if notebooks have an accent in their name? | |
201 | """ |
|
202 | """ | |
202 |
with self.create_temp_cwd( |
|
203 | with self.create_temp_cwd(): | |
|
204 | self.create_empty_notebook(u'nb1_análisis.ipynb') | |||
203 | o,e = self.call('nbconvert --log-level 0 --to latex ' |
|
205 | o,e = self.call('nbconvert --log-level 0 --to latex ' | |
204 | '"nb1_*" --post PDF ' |
|
206 | '"nb1_*" --post PDF ' | |
205 | '--PDFPostProcessor.verbose=True') |
|
207 | '--PDFPostProcessor.verbose=True') |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now