Skip to content

Commit 11f1f93

Browse files
committed
fix import mixup in tests
1 parent 7e472ea commit 11f1f93

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

plotly/tests/test_optional/test_offline/test_offline.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,32 @@
33
44
"""
55
from __future__ import absolute_import
6-
from nose.tools import raises
76
from unittest import TestCase
87
import os
98

10-
from plotly.exceptions import PlotlyOfflineNotFound
11-
import plotly
12-
139

1410
class PlotlyOfflineTestCase(TestCase):
15-
@raises(PlotlyOfflineNotFound)
1611
def test_initializing_before_downloading_raises_an_error(self):
12+
# Delete the offline directory importing plotly
13+
# Requires hardcoding this directory into the test
14+
# from utils.py because simply importing plotly will set the
15+
# __PLOTLY_OFFLINE_INITIALIZED flag
16+
PLOTLY_OFFLINE_DIRECTORY = os.path.expanduser(
17+
os.path.join(*'~/.plotly/plotlyjs'.split('/')))
18+
PLOTLY_OFFLINE_BUNDLE = os.path.join(PLOTLY_OFFLINE_DIRECTORY,
19+
'plotly-ipython-offline-bundle.js')
20+
1721
try:
18-
os.remove(plotly.offline.offline.PLOTLY_OFFLINE_BUNDLE)
22+
os.remove(PLOTLY_OFFLINE_BUNDLE)
1923
except OSError:
2024
pass
2125

22-
plotly.offline.iplot([{'x': [1, 2, 3]}])
26+
from plotly.exceptions import PlotlyOfflineNotFound
27+
import plotly
28+
29+
try:
30+
plotly.offline.iplot([{'x': [1, 2, 3]}])
31+
except PlotlyOfflineNotFound:
32+
pass
33+
else:
34+
raise Exception("PlotlyOfflineNotFound wasn't raised")

0 commit comments

Comments
 (0)