@@ -25,9 +25,7 @@ def normalize_output(output):
25
25
if 'traceback' in output :
26
26
del output ['traceback' ]
27
27
if 'application/vnd.jupyter.widget-view+json' in output .get ('data' , {}):
28
- output ['data' ]['application/vnd.jupyter.widget-view+json' ][
29
- 'model_id'
30
- ] = '<MODEL_ID>'
28
+ output ['data' ]['application/vnd.jupyter.widget-view+json' ]['model_id' ] = '<MODEL_ID>'
31
29
32
30
33
31
def normalize_outputs (outputs ):
@@ -36,31 +34,24 @@ def normalize_outputs(outputs):
36
34
37
35
38
36
def test_execute_output ():
39
- path = os .path .join (BASE_DIR , ' notebooks/output.ipynb' )
37
+ path = os .path .join (BASE_DIR , " notebooks/output.ipynb" )
40
38
nb = read (path , NO_CONVERT )
41
39
nb_voila = deepcopy (nb )
42
40
executenb (nb_voila )
43
41
44
42
widget_states = nb .metadata .widgets [WIDGET_MIME_TYPE_STATE ]['state' ]
45
- widget_states_voila = nb_voila .metadata .widgets [WIDGET_MIME_TYPE_STATE ][
46
- 'state'
47
- ]
43
+ widget_states_voila = nb_voila .metadata .widgets [WIDGET_MIME_TYPE_STATE ]['state' ]
48
44
49
45
for cell_voila , cell in zip (nb_voila .cells , nb .cells ):
50
46
for output_voila , output in zip (cell_voila .outputs , cell .outputs ):
51
47
if 'data' in output and WIDGET_MIME_TYPE_VIEW in output ['data' ]:
52
48
widget_id = output ['data' ][WIDGET_MIME_TYPE_VIEW ]['model_id' ]
53
- widget_id_voila = output_voila ['data' ][WIDGET_MIME_TYPE_VIEW ][
54
- 'model_id'
55
- ]
49
+ widget_id_voila = output_voila ['data' ][WIDGET_MIME_TYPE_VIEW ]['model_id' ]
56
50
widget_state = widget_states [widget_id ]
57
51
widget_state_voila = widget_states_voila [widget_id_voila ]
58
52
# if the widget is an output widget, it has the outputs, which we also check
59
- assert normalize_outputs (
60
- widget_state .state .get ('outputs' , [])
61
- ) == normalize_outputs (
62
- widget_state_voila .state .get ('outputs' , [])
63
- )
53
+ assert normalize_outputs (widget_state .state .get ('outputs' , [])) == \
54
+ normalize_outputs (widget_state_voila .state .get ('outputs' , []))
64
55
normalize_output (output_voila )
65
56
normalize_output (output )
66
57
assert output_voila == output
0 commit comments