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