|
4 | 4 | """
|
5 | 5 | from __future__ import absolute_import
|
6 | 6 |
|
7 |
| -import os |
8 |
| -from nose.plugins.attrib import attr |
9 | 7 | from nose.tools import raises
|
10 | 8 | from unittest import TestCase
|
11 | 9 |
|
12 | 10 | import plotly
|
13 |
| -from plotly.exceptions import PlotlyError |
14 |
| - |
15 |
| -dummy_js_url = ('https://gist.githubusercontent.com/chriddyp/' |
16 |
| - 'f40bd33d1eab6f0715dc/raw/' |
17 |
| - '24cd2e4e62ceea79e6e790b3a2c94cda63510ede/' |
18 |
| - 'test.js') |
19 | 11 |
|
20 | 12 |
|
21 | 13 | class PlotlyOfflineTestCase(TestCase):
|
22 |
| - def _remove_plotlyjs(self): |
23 |
| - try: |
24 |
| - os.remove(plotly.offline.offline.PLOTLY_OFFLINE_BUNDLE) |
25 |
| - except OSError: |
26 |
| - pass |
27 |
| - |
28 |
| - def test_no_errors_are_raised_when_initializing_offline_mode(self): |
29 |
| - self._remove_plotlyjs() |
30 |
| - plotly.offline.download_plotlyjs(dummy_js_url) |
31 |
| - plotly.offline.init_notebook_mode() |
32 |
| - plotly.offline.iplot([{'x': [1, 2, 3]}]) |
| 14 | + def setUp(self): |
| 15 | + plotly.offline.offline.__PLOTLY_OFFLINE_INITIALIZED = False |
33 | 16 |
|
34 |
| - @attr('slow') |
35 |
| - @raises(PlotlyError) |
36 |
| - def test_calling_iplot_before_initializing_raises_an_error(self): |
37 |
| - self._remove_plotlyjs() |
38 |
| - plotly.offline.download_plotlyjs(dummy_js_url) |
39 |
| - plotly.offline.iplot([{'x': [1, 2, 3]}]) |
| 17 | + @raises(plotly.exceptions.PlotlyError) |
| 18 | + def test_iplot_doesnt_work_before_you_call_init_notebook_mode(self): |
| 19 | + plotly.offline.iplot([{}]) |
40 | 20 |
|
41 |
| - @raises(PlotlyError) |
42 |
| - def test_initializing_before_downloading_raises_an_error(self): |
43 |
| - self._remove_plotlyjs() |
| 21 | + def test_iplot_works_after_you_call_init_notebook_mode(self): |
| 22 | + plotly.tools._ipython_imported = True |
44 | 23 | plotly.offline.init_notebook_mode()
|
| 24 | + plotly.offline.iplot([{}]) |
0 commit comments