Skip to content

Commit b728b69

Browse files
committed
Fix optional and plot_ly tests
1 parent bf479ec commit b728b69

File tree

5 files changed

+27
-20
lines changed

5 files changed

+27
-20
lines changed

plotly/tests/test_core/test_graph_objs/test_graph_objs.py

+6
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ def test_title_as_string_layout(self):
5353
self.assertEqual(obj.to_plotly_json(),
5454
{'title': {'text': 'A title'}})
5555

56+
# And update
57+
obj.update(title='A title 2')
58+
self.assertEqual(obj.title.text, 'A title 2')
59+
self.assertEqual(obj.to_plotly_json(),
60+
{'title': {'text': 'A title 2'}})
61+
5662
# Pie
5763
obj = go.Pie()
5864
obj.title = 'A title'

plotly/tests/test_optional/test_figure_factory/test_figure_factory.py

+16-16
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def test_distplot_more_args_prob_dens(self):
165165
'yaxis': {'anchor': 'free',
166166
'domain': [0.0, 1],
167167
'position': 0.0},
168-
'title': 'Dist Plot'}
168+
'title': {'text': 'Dist Plot'}}
169169
self.assert_fig_equal(dp['layout'], expected_dp_layout)
170170

171171
expected_dp_data_hist_1 = {'autobinx': False,
@@ -223,7 +223,7 @@ def test_distplot_more_args_prob(self):
223223
expected_dp_layout = {'barmode': 'overlay',
224224
'hovermode': 'closest',
225225
'legend': {'traceorder': 'reversed'},
226-
'title': 'Dist Plot',
226+
'title': {'text': 'Dist Plot'},
227227
'xaxis': {'anchor': 'y2',
228228
'domain': [0.0, 1.0],
229229
'zeroline': False},
@@ -948,7 +948,7 @@ def test_trisurf_all_args(self):
948948
'gridcolor': 'rgb(255, 255, 255)',
949949
'showbackground': True,
950950
'zerolinecolor': 'rgb(255, 255, 255)'}},
951-
'title': 'Trisurf Plot',
951+
'title': {'text': 'Trisurf Plot'},
952952
'width': 800}
953953
}
954954

@@ -1227,7 +1227,7 @@ def test_scatter_plot_matrix(self):
12271227
'yaxis': 'y4'}],
12281228
'layout': {'height': 1000,
12291229
'showlegend': True,
1230-
'title': 'Scatterplot Matrix',
1230+
'title': {'text': 'Scatterplot Matrix'},
12311231
'width': 1000,
12321232
'xaxis': {'anchor': 'y',
12331233
'domain': [0.0, 0.45],
@@ -1236,19 +1236,19 @@ def test_scatter_plot_matrix(self):
12361236
'domain': [0.55, 1.0]},
12371237
'xaxis3': {'anchor': 'y3',
12381238
'domain': [0.0, 0.45],
1239-
'title': 'Numbers'},
1239+
'title': {'text': 'Numbers'}},
12401240
'xaxis4': {'anchor': 'y4',
12411241
'domain': [0.55, 1.0],
12421242
'showticklabels': False,
1243-
'title': 'Fruit'},
1243+
'title': {'text': 'Fruit'}},
12441244
'yaxis': {'anchor': 'x',
12451245
'domain': [0.575, 1.0],
1246-
'title': 'Numbers'},
1246+
'title': {'text': 'Numbers'}},
12471247
'yaxis2': {'anchor': 'x2',
12481248
'domain': [0.575, 1.0]},
12491249
'yaxis3': {'anchor': 'x3',
12501250
'domain': [0.0, 0.425],
1251-
'title': 'Fruit'},
1251+
'title': {'text': 'Fruit'}},
12521252
'yaxis4': {'anchor': 'x4',
12531253
'domain': [0.0, 0.425]}}
12541254
}
@@ -1293,14 +1293,14 @@ def test_scatter_plot_matrix_kwargs(self):
12931293
'layout': {'barmode': 'stack',
12941294
'height': 1000,
12951295
'showlegend': True,
1296-
'title': 'Scatterplot Matrix',
1296+
'title': {'text': 'Scatterplot Matrix'},
12971297
'width': 1000,
12981298
'xaxis': {'anchor': 'y',
12991299
'domain': [0.0, 1.0],
1300-
'title': 'Numbers'},
1300+
'title': {'text': 'Numbers'}},
13011301
'yaxis': {'anchor': 'x',
13021302
'domain': [0.0, 1.0],
1303-
'title': 'Numbers'}}
1303+
'title': {'text': 'Numbers'}}}
13041304
}
13051305

13061306
self.assert_fig_equal(test_scatter_plot_matrix['data'][0],
@@ -1364,7 +1364,7 @@ def test_df_dataframe_all_args(self):
13641364
'y1': 1.2,
13651365
'yref': 'y'}],
13661366
'showlegend': False,
1367-
'title': 'Gantt Chart',
1367+
'title': {'text': 'Gantt Chart'},
13681368
'width': 900,
13691369
'xaxis': {'rangeselector': {'buttons': [{'count': 7,
13701370
'label': '1w',
@@ -1963,7 +1963,7 @@ def test_violin_fig(self):
19631963
'height': 450,
19641964
'hovermode': 'closest',
19651965
'showlegend': False,
1966-
'title': 'Violin and Rug Plot',
1966+
'title': {'text': 'Violin and Rug Plot'},
19671967
'width': 600,
19681968
'xaxis': {'mirror': False,
19691969
'range': [-0.65916964093970665,
@@ -1972,7 +1972,7 @@ def test_violin_fig(self):
19721972
'showline': False,
19731973
'showticklabels': False,
19741974
'ticks': '',
1975-
'title': '',
1975+
'title': {'text': ''},
19761976
'zeroline': False},
19771977
'yaxis': {'autorange': True,
19781978
'mirror': False,
@@ -1981,7 +1981,7 @@ def test_violin_fig(self):
19811981
'showticklabels': False,
19821982
'ticklen': 4,
19831983
'ticks': '',
1984-
'title': '',
1984+
'title': {'text': ''},
19851985
'zeroline': False}}}
19861986

19871987
# test both items in 'data'
@@ -2184,7 +2184,7 @@ def test_valid_facet_grid_fig(self):
21842184
'yanchor': 'top'},
21852185
'paper_bgcolor': 'rgb(251, 251, 251)',
21862186
'showlegend': False,
2187-
'title': '',
2187+
'title': {'text': ''},
21882188
'width': 600,
21892189
'xaxis': {'anchor': 'y',
21902190
'domain': [0.0, 0.4925],

plotly/tests/test_optional/test_plotly/test_plot_mpl.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,4 @@ def test_update(self):
5555
un = url.replace("https://plot.ly/~", "").split('/')[0]
5656
fid = url.replace("https://plot.ly/~", "").split('/')[1]
5757
pfig = py.get_figure(un, fid)
58-
assert pfig['layout']['title'] == title
58+
assert pfig['layout']['title']['text'] == title

plotly/tests/test_optional/test_tools/test_figure_factory.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1750,7 +1750,7 @@ def test_2D_density_all_args(self):
17501750
'hovermode': 'closest',
17511751
'margin': {'t': 50},
17521752
'showlegend': False,
1753-
'title': '2D Density Plot',
1753+
'title': {'text': '2D Density Plot'},
17541754
'width': 800,
17551755
'xaxis': {'domain': [0, 0.85],
17561756
'showgrid': False,

plotly/tests/test_plot_ly/test_plotly/test_plot.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,14 @@ def test_plot_valid(self):
4545
'y': (2, 1, 2)
4646
}
4747
],
48-
'layout': {'title': 'simple'}
48+
'layout': {'title': {'text': 'simple'}}
4949
}
5050
url = py.plot(fig, auto_open=False, filename='plot_valid')
5151
saved_fig = py.get_figure(url)
5252
self.assertEqual(saved_fig['data'][0]['x'], fig['data'][0]['x'])
5353
self.assertEqual(saved_fig['data'][0]['y'], fig['data'][0]['y'])
54-
self.assertEqual(saved_fig['layout']['title'], fig['layout']['title'])
54+
self.assertEqual(saved_fig['layout']['title']['text'],
55+
fig['layout']['title']['text'])
5556

5657
def test_plot_invalid(self):
5758
fig = {

0 commit comments

Comments
 (0)