Skip to content

Commit

Permalink
separated ipynb_remove_output.py and nb_file_util.py
Browse files Browse the repository at this point in the history
  • Loading branch information
kangwonlee committed Dec 26, 2017
1 parent 8f2651c commit 10ae99a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 22 deletions.
24 changes: 2 additions & 22 deletions test_nbutils.py → test_nb_file_util.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import unittest

import ipynb_remove_output as nbutils
import nb_file_util as nbutils

null = dir(nbutils)


class TestNButils(unittest.TestCase):
class TestNotebookFileUtil(unittest.TestCase):
def setUp(self):
self.input_file_name = 'sample.ipynb'
self.file_processor = nbutils.FileProcessor(self.input_file_name)
Expand Down Expand Up @@ -45,26 +45,6 @@ def test_has_symbol(self):

self.assertSequenceEqual(expected, result)

def test_cells_with_symbol(self):
self.maxDiff = None
result = nbutils.symbol_lines_in_file(self.input_file_name)

# compare with an expected list
expected_result = [{'cell number': 8, 'result': [
{'line number': 0, 'source': "L_AB_m = sy.symbols('L_AB_m', real=True, nonnegative=True)"}]},
{'cell number': 10,
'result': [{'line number': 0, 'source': "w0_N_m = sy.symbols('w0_N_m', real=True)"}]},
{'cell number': 12, 'result': [
{'line number': 0, 'source': "E_Pa, I_m4 = sy.symbols('E_Pa, I_m4', positive=True)"}]},
{'cell number': 14,
'result': [{'line number': 0, 'source': "x_m = sy.symbols('x_m', nonnegative=True)"}]},
{'cell number': 16, 'result': [{'line number': 0,
'source': "R_A_N, M_A_Nm, R_B_N = sy.symbols('R_A_N, M_A_Nm, R_B_N', real=True)"}]}]
expected = {'file name': self.input_file_name,
'result': expected_result}

self.assertDictEqual(expected, result)

def test_replace_symbol(self):
self.maxDiff = None
file = self.file_processor.read_file()
Expand Down
28 changes: 28 additions & 0 deletions test_remove_output.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import unittest

import ipynb_remove_output as nbutils


class TestRemoveOutput(unittest.TestCase):
def setUp(self):
self.input_file_name = 'sample.ipynb'

def test_cells_with_symbol(self):
self.maxDiff = None
result = nbutils.symbol_lines_in_file(self.input_file_name)

# compare with an expected list
expected_result = [{'cell number': 8, 'result': [
{'line number': 0, 'source': "L_AB_m = sy.symbols('L_AB_m', real=True, nonnegative=True)"}]},
{'cell number': 10,
'result': [{'line number': 0, 'source': "w0_N_m = sy.symbols('w0_N_m', real=True)"}]},
{'cell number': 12, 'result': [
{'line number': 0, 'source': "E_Pa, I_m4 = sy.symbols('E_Pa, I_m4', positive=True)"}]},
{'cell number': 14,
'result': [{'line number': 0, 'source': "x_m = sy.symbols('x_m', nonnegative=True)"}]},
{'cell number': 16, 'result': [{'line number': 0,
'source': "R_A_N, M_A_Nm, R_B_N = sy.symbols('R_A_N, M_A_Nm, R_B_N', real=True)"}]}]
expected = {'file name': self.input_file_name,
'result': expected_result}

self.assertDictEqual(expected, result)

0 comments on commit 10ae99a

Please sign in to comment.