|
10 | 10 | from plotly.exceptions import PlotlyError
|
11 | 11 | import plotly
|
12 | 12 |
|
| 13 | +dummy_js_url = ('https://gist.githubusercontent.com/chriddyp/' |
| 14 | + 'f40bd33d1eab6f0715dc/raw/' |
| 15 | + '24cd2e4e62ceea79e6e790b3a2c94cda63510ede/' |
| 16 | + 'test.js') |
| 17 | + |
13 | 18 |
|
14 | 19 | 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 |
18 | 25 |
|
19 | 26 | def test_no_errors_are_raised_when_initializing_offline_mode(self):
|
| 27 | + self._remove_plotlyjs() |
| 28 | + plotly.offline.download_plotlyjs(dummy_js_url) |
20 | 29 | plotly.offline.init_notebook_mode()
|
21 | 30 | plotly.offline.iplot([{'x': [1, 2, 3]}])
|
22 | 31 |
|
23 | 32 | @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]}]) |
29 | 37 |
|
| 38 | + @raises(PlotlyError) |
| 39 | + def test_initializing_before_downloading_raises_an_error(self): |
| 40 | + self._remove_plotlyjs() |
30 | 41 | plotly.offline.init_notebook_mode()
|
0 commit comments