Skip to content

Commit

Permalink
added test_has_symbol() : compare the results from cells
Browse files Browse the repository at this point in the history
  • Loading branch information
kangwonlee committed Dec 24, 2017
1 parent b31aff9 commit b847d7d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test_nbutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@ def test_read_notebook(self):
self.assertIn('nbformat', result)
self.assertIn('nbformat_minor', result)

def test_has_symbol(self):
file = nbutils.read_file(self.input_file_name)
cells = file['cells']
result = []
for k, cell in enumerate(cells):
cell_result = nbutils.has_symbol(cell)
if cell_result:
result.append((k, cell_result))

# compare with an expected list
expected = [(8, [(0, "L_AB_m = sy.symbols('L_AB_m', real=True, nonnegative=True)")]),
(10, [(0, "w0_N_m = sy.symbols('w0_N_m', real=True)")]),
(12, [(0, "E_Pa, I_m4 = sy.symbols('E_Pa, I_m4', positive=True)")]),
(14, [(0, "x_m = sy.symbols('x_m', nonnegative=True)")]),
(16, [(0, "R_A_N, M_A_Nm, R_B_N = sy.symbols('R_A_N, M_A_Nm, R_B_N', real=True)")])]

self.assertSequenceEqual(expected, result)


def _exec_notebook(path):
# http://nbconvert.readthedocs.io/en/latest/execute_api.html
Expand Down

0 comments on commit b847d7d

Please sign in to comment.