Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2793609

Browse files
committed
refactor tests to handle core vs optional deps (ipython)
1 parent 5a9f445 commit 2793609

File tree

2 files changed

+32
-23
lines changed

2 files changed

+32
-23
lines changed

plotly/tests/test_core/test_offline/test_offline.py

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,16 @@
33
44
"""
55
from __future__ import absolute_import
6-
from nose.tools import raises
7-
import os
86

7+
import os
98

10-
from plotly.exceptions import PlotlyError
119
import plotly
1210

1311

14-
@raises(PlotlyError)
15-
def test_calling_iplot_before_initializing_raises_an_error():
16-
plotly.offline.iplot([{'x': [1, 2, 3]}])
17-
18-
19-
def test_no_errors_are_raised_when_properly_initializing_offline_mode():
20-
plotly.offline.init_notebook_mode()
21-
plotly.offline.iplot([{'x': [1, 2, 3]}])
22-
23-
2412
def test_downloading_file_saves_it_to_the_disk():
2513
dummy_js_url = ('https://gist.githubusercontent.com/chriddyp/'
2614
'f40bd33d1eab6f0715dc/raw/'
2715
'24cd2e4e62ceea79e6e790b3a2c94cda63510ede/test.js')
2816

2917
plotly.offline.download_plotlyjs(dummy_js_url)
3018
assert os.path.isfile(plotly.offline.PLOTLY_OFFLINE_BUNDLE) is True
31-
32-
33-
@raises(PlotlyError)
34-
def test_initializing_before_downloading_raises_an_error():
35-
try:
36-
os.remove(plotly.offline.PLOTLY_OFFLINE_BUNDLE)
37-
except OSError:
38-
pass
39-
40-
plotly.offline.init_notebook_mode()
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""
2+
test__offline
3+
4+
"""
5+
from __future__ import absolute_import
6+
from nose.tools import raises
7+
import os
8+
9+
10+
from plotly.exceptions import PlotlyError
11+
import plotly
12+
13+
14+
@raises(PlotlyError)
15+
def test_calling_iplot_before_initializing_raises_an_error():
16+
plotly.offline.iplot([{'x': [1, 2, 3]}])
17+
18+
19+
def test_no_errors_are_raised_when_properly_initializing_offline_mode():
20+
plotly.offline.init_notebook_mode()
21+
plotly.offline.iplot([{'x': [1, 2, 3]}])
22+
23+
24+
@raises(PlotlyError)
25+
def test_initializing_before_downloading_raises_an_error():
26+
try:
27+
os.remove(plotly.offline.PLOTLY_OFFLINE_BUNDLE)
28+
except OSError:
29+
pass
30+
31+
plotly.offline.init_notebook_mode()

0 commit comments

Comments
 (0)