##// END OF EJS Templates
Add some unicode testing for saving notebooks
Thomas Kluyver -
Show More
@@ -198,16 +198,20 b' class APITest(NotebookTestBase):'
198 nb = to_notebook_json(nbcontent)
198 nb = to_notebook_json(nbcontent)
199 ws = new_worksheet()
199 ws = new_worksheet()
200 nb.worksheets = [ws]
200 nb.worksheets = [ws]
201 ws.cells.append(new_heading_cell('Created by test'))
201 ws.cells.append(new_heading_cell(u'Created by test ³'))
202
202
203 nbmodel= {'name': 'a.ipynb', 'path':'foo', 'content': nb}
203 nbmodel= {'name': 'a.ipynb', 'path':'foo', 'content': nb}
204 resp = self.nb_api.save('a.ipynb', path='foo', body=jsonapi.dumps(nbmodel))
204 resp = self.nb_api.save('a.ipynb', path='foo', body=jsonapi.dumps(nbmodel))
205
205
206 nbfile = pjoin(self.notebook_dir.name, 'foo', 'a.ipynb')
206 nbfile = pjoin(self.notebook_dir.name, 'foo', 'a.ipynb')
207 with open(nbfile, 'r') as f:
207 with io.open(nbfile, 'r', encoding='utf-8') as f:
208 newnb = read(f, format='ipynb')
208 newnb = read(f, format='ipynb')
209 self.assertEqual(newnb.worksheets[0].cells[0].source,
209 self.assertEqual(newnb.worksheets[0].cells[0].source,
210 'Created by test')
210 u'Created by test ³')
211 nbcontent = self.nb_api.read('a.ipynb', 'foo').json()['content']
212 newnb = to_notebook_json(nbcontent)
213 self.assertEqual(newnb.worksheets[0].cells[0].source,
214 u'Created by test ³')
211
215
212 # Save and rename
216 # Save and rename
213 nbmodel= {'name': 'a2.ipynb', 'path':'foo/bar', 'content': nb}
217 nbmodel= {'name': 'a2.ipynb', 'path':'foo/bar', 'content': nb}
General Comments 0
You need to be logged in to leave comments. Login now