From f9280494cb0dbb45ee73929f4a568978477de6c2 Mon Sep 17 00:00:00 2001 From: KangWon Lee Date: Mon, 25 Dec 2017 21:41:49 +0900 Subject: [PATCH] started FileProcessor : file interface : read, write, run ipynb --- test_nbutils.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/test_nbutils.py b/test_nbutils.py index 1cb849f..387d3da 100644 --- a/test_nbutils.py +++ b/test_nbutils.py @@ -1,4 +1,3 @@ -import subprocess import unittest import ipynb_remove_output as nbutils @@ -9,10 +8,11 @@ class TestNButils(unittest.TestCase): def setUp(self): self.input_file_name = 'sample.ipynb' + self.file_processor = nbutils.FileProcessor(self.input_file_name) def test_sample_ipynb(self): # should run without an exception - _exec_notebook(self.input_file_name) + self.file_processor.execute() def test_read_notebook(self): result = nbutils.read_file(self.input_file_name) @@ -69,15 +69,6 @@ def test_replace_symbol(self): self.assertSequenceEqual(expected, result) -def _exec_notebook(path): - # http://nbconvert.readthedocs.io/en/latest/execute_api.html - # ijstokes et al, Command line execution of a jupyter notebook fails in default Anaconda 4.1, https://github.com/Anaconda-Platform/nb_conda_kernels/issues/34 - args = ["jupyter", "nbconvert", "--to", "notebook", "--execute", - "--ExecutePreprocessor.timeout=1000", - "--ExecutePreprocessor.kernel_name=python", path] - subprocess.check_call(args) - - if __name__ == '__main__': unittest.main() # finished running