##// END OF EJS Templates
Refactor assert_notebooks_equal
Julia Evans -
Show More
@@ -25,7 +25,11 b' from ..execute import ExecutePreprocessor'
25 class TestExecute(PreprocessorTestsBase):
25 class TestExecute(PreprocessorTestsBase):
26 """Contains test functions for execute.py"""
26 """Contains test functions for execute.py"""
27
27
28 def prepare_cell(self, cell):
28 @staticmethod
29 def normalize_cell(cell):
30 """
31 Normalizes cells for comparison.
32 """
29 cell = dict(cell)
33 cell = dict(cell)
30 if 'metadata' in cell:
34 if 'metadata' in cell:
31 del cell['metadata']
35 del cell['metadata']
@@ -41,13 +45,12 b' class TestExecute(PreprocessorTestsBase):'
41 actual_cells = actual['worksheets'][0]['cells']
45 actual_cells = actual['worksheets'][0]['cells']
42 assert len(expected_cells) == len(actual_cells)
46 assert len(expected_cells) == len(actual_cells)
43
47
44 # TODO: what does this code do?
48 for expected_cell, actual_cell in zip(expected_cells, actual_cells):
45 for expected_out, actual_out in zip(expected_cells, actual_cells):
49 expected_outputs = expected_cell.get('outputs', [])
46 for k in set(expected_out).union(actual_out):
50 actual_outputs = actual_cell.get('outputs', [])
47 if k == 'outputs':
51 normalized_expected_outputs = map(self.normalize_cell, expected_outputs)
48 self.assertEquals(len(expected_out[k]), len(actual_out[k]))
52 normalized_actual_outputs = map(self.normalize_cell, actual_outputs)
49 for e, a in zip(expected_out[k], actual_out[k]):
53 assert normalized_expected_outputs == normalized_actual_outputs
50 assert self.prepare_cell(e) == self.prepare_cell(a)
51
54
52
55
53 def build_preprocessor(self):
56 def build_preprocessor(self):
General Comments 0
You need to be logged in to leave comments. Login now