##// END OF EJS Templates
Merge pull request #4496 from takluyver/i4495...
Min RK -
r13515:39456020 merge
parent child Browse files
Show More
@@ -251,7 +251,7 b' class FileNotebookManager(NotebookManager):'
251 self.log.debug("Writing script %s", py_path)
251 self.log.debug("Writing script %s", py_path)
252 try:
252 try:
253 with io.open(py_path, 'w', encoding='utf-8') as f:
253 with io.open(py_path, 'w', encoding='utf-8') as f:
254 current.write(model, f, u'py')
254 current.write(nb, f, u'py')
255 except Exception as e:
255 except Exception as e:
256 raise web.HTTPError(400, u'Unexpected error while saving notebook as script: %s %s' % (py_path, e))
256 raise web.HTTPError(400, u'Unexpected error while saving notebook as script: %s %s' % (py_path, e))
257
257
@@ -196,6 +196,25 b' class TestNotebookManager(TestCase):'
196 self.assertEqual(model['name'], 'Untitled0.ipynb')
196 self.assertEqual(model['name'], 'Untitled0.ipynb')
197 self.assertEqual(model['path'], sub_dir.strip('/'))
197 self.assertEqual(model['path'], sub_dir.strip('/'))
198
198
199 def test_save_notebook_with_script(self):
200 with TemporaryDirectory() as td:
201 # Create a notebook
202 nm = FileNotebookManager(notebook_dir=td)
203 nm.save_script = True
204 model = nm.create_notebook_model()
205 name = model['name']
206 path = model['path']
207
208 # Get the model with 'content'
209 full_model = nm.get_notebook_model(name, path)
210
211 # Save the notebook
212 model = nm.save_notebook_model(full_model, name, path)
213
214 # Check that the script was created
215 py_path = os.path.join(td, os.path.splitext(name)[0]+'.py')
216 assert os.path.exists(py_path), py_path
217
199 def test_delete_notebook_model(self):
218 def test_delete_notebook_model(self):
200 with TemporaryDirectory() as td:
219 with TemporaryDirectory() as td:
201 # Test in the root directory
220 # Test in the root directory
General Comments 0
You need to be logged in to leave comments. Login now