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

Skip to content

Commit 3d95463

Browse files
committed
TestCase for the :habit: hamster, this one's for you @theengineear
1 parent 1552f8e commit 3d95463

File tree

2 files changed

+23
-22
lines changed

2 files changed

+23
-22
lines changed

plotly/tests/test_core/test_offline/test_offline.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55
from __future__ import absolute_import
66

77
import os
8+
from unittest import TestCase
89

910
import plotly
1011

1112

12-
def test_downloading_file_saves_it_to_the_disk():
13-
dummy_js_url = ('https://gist.githubusercontent.com/chriddyp/'
14-
'f40bd33d1eab6f0715dc/raw/'
15-
'24cd2e4e62ceea79e6e790b3a2c94cda63510ede/test.js')
13+
class PlotlyOfflineTestCase(TestCase):
14+
def test_downloading_file_saves_it_to_the_disk(self):
15+
dummy_js_url = ('https://gist.githubusercontent.com/chriddyp/'
16+
'f40bd33d1eab6f0715dc/raw/'
17+
'24cd2e4e62ceea79e6e790b3a2c94cda63510ede/test.js')
1618

17-
plotly.offline.download_plotlyjs(dummy_js_url)
18-
assert os.path.isfile(plotly.offline.PLOTLY_OFFLINE_BUNDLE) is True
19+
plotly.offline.download_plotlyjs(dummy_js_url)
20+
assert os.path.isfile(plotly.offline.PLOTLY_OFFLINE_BUNDLE) is True

plotly/tests/test_optional/test_offline/test_offline.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,27 @@
44
"""
55
from __future__ import absolute_import
66
from nose.tools import raises
7+
from unittest import TestCase
78
import os
89

9-
1010
from plotly.exceptions import PlotlyError
1111
import plotly
1212

1313

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]}])
14+
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]}])
2218

19+
def test_no_errors_are_raised_when_initializing_offline_mode(self):
20+
plotly.offline.init_notebook_mode()
21+
plotly.offline.iplot([{'x': [1, 2, 3]}])
2322

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
23+
@raises(PlotlyError)
24+
def test_initializing_before_downloading_raises_an_error(self):
25+
try:
26+
os.remove(plotly.offline.PLOTLY_OFFLINE_BUNDLE)
27+
except OSError:
28+
pass
3029

31-
plotly.offline.init_notebook_mode()
30+
plotly.offline.init_notebook_mode()

0 commit comments

Comments
 (0)