示例#1
0
 def test(self):
     nb_test1_fname = get_notebook_path('simple_execute.ipynb')
     nb_test1_executed_fname = os.path.join(self.test_dir, 'test1_executed.ipynb')
     execute_notebook(nb_test1_fname, nb_test1_executed_fname, {'msg': 'Hello'})
     test_nb = read_notebook(nb_test1_executed_fname)
     self.assertEqual(test_nb.node.cells[0].get('source'), u'# Parameters\nmsg = "Hello"\n')
     self.assertEqual(test_nb.parameters, {'msg': 'Hello'})
示例#2
0
 def test(self):
     path = get_notebook_path('broken.ipynb')
     result_path = os.path.join(self.test_dir, 'broken.ipynb')
     execute_notebook(path, result_path)
     nb = read_notebook(result_path)
     self.assertEqual(nb.node.cells[0].execution_count, 1)
     self.assertEqual(nb.node.cells[1].execution_count, 2)
     self.assertEqual(nb.node.cells[1].outputs[0].output_type, 'error')
     self.assertEqual(nb.node.cells[2].execution_count, None)
示例#3
0
 def test(self):
     path = get_notebook_path('broken.ipynb')
     result_path = os.path.join(self.test_dir, 'broken.ipynb')
     with self.assertRaises(PapermillExecutionError):
         execute_notebook(path, result_path)
     nb = read_notebook(result_path)
     self.assertEqual(nb.node.cells[0].cell_type, "markdown")
     self.assertEqual(nb.node.cells[1].execution_count, 1)
     self.assertEqual(nb.node.cells[2].execution_count, 2)
     self.assertEqual(nb.node.cells[2].outputs[0].output_type, 'error')
     self.assertEqual(nb.node.cells[3].execution_count, None)