Skip to content

Commit bb72482

Browse files
committed
fix tests
1 parent e94e66c commit bb72482

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

plotly/tests/test_optional/test_offline/test_offline.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,32 @@
1010
from plotly.exceptions import PlotlyError
1111
import plotly
1212

13+
dummy_js_url = ('https://gist.githubusercontent.com/chriddyp/'
14+
'f40bd33d1eab6f0715dc/raw/'
15+
'24cd2e4e62ceea79e6e790b3a2c94cda63510ede/'
16+
'test.js')
17+
1318

1419
class PlotlyOfflineTestCase(TestCase):
15-
@raises(PlotlyError)
16-
def test_calling_iplot_before_initializing_raises_an_error(self):
17-
plotly.offline.iplot([{'x': [1, 2, 3]}])
20+
def _remove_plotlyjs(self):
21+
try:
22+
os.remove(plotly.offline.offline.PLOTLY_OFFLINE_BUNDLE)
23+
except OSError:
24+
pass
1825

1926
def test_no_errors_are_raised_when_initializing_offline_mode(self):
27+
self._remove_plotlyjs()
28+
plotly.offline.download_plotlyjs(dummy_js_url)
2029
plotly.offline.init_notebook_mode()
2130
plotly.offline.iplot([{'x': [1, 2, 3]}])
2231

2332
@raises(PlotlyError)
24-
def test_initializing_before_downloading_raises_an_error(self):
25-
try:
26-
os.remove(plotly.offline.offline.PLOTLY_OFFLINE_BUNDLE)
27-
except OSError:
28-
pass
33+
def test_calling_iplot_before_initializing_raises_an_error(self):
34+
self._remove_plotlyjs()
35+
plotly.offline.download_plotlyjs(dummy_js_url)
36+
plotly.offline.iplot([{'x': [1, 2, 3]}])
2937

38+
@raises(PlotlyError)
39+
def test_initializing_before_downloading_raises_an_error(self):
40+
self._remove_plotlyjs()
3041
plotly.offline.init_notebook_mode()

0 commit comments

Comments
 (0)