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

Skip to content

Commit 99b8a9b

Browse files
committed
Merge pull request plotly#238 from plotly/fix-master
Fix failing test and refact to TestCase.
2 parents bf3c687 + 74a5d62 commit 99b8a9b

File tree

2 files changed

+32
-32
lines changed

2 files changed

+32
-32
lines changed

plotly/tests/test_core/test_file/test_file.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,47 +5,47 @@
55
A module intended for use with Nose.
66
77
"""
8-
9-
from nose.tools import raises
10-
from nose import with_setup
11-
128
import random
139
import string
14-
import requests
10+
from unittest import TestCase
1511

1612
import plotly.plotly as py
17-
import plotly.tools as tls
1813
from plotly.exceptions import PlotlyRequestError
1914

2015

21-
def _random_filename():
22-
random_chars = [random.choice(string.ascii_uppercase) for _ in range(5)]
23-
unique_filename = 'Valid Folder'+''.join(random_chars)
24-
return unique_filename
25-
26-
27-
def init():
28-
py.sign_in('PythonTest', '9v9f20pext')
29-
16+
class FolderAPITestCase(TestCase):
3017

31-
@with_setup(init)
32-
def test_create_folder():
33-
py.file_ops.mkdirs(_random_filename())
18+
def setUp(self):
19+
py.sign_in('PythonTest', '9v9f20pext')
3420

21+
def _random_filename(self):
22+
random_chars = [random.choice(string.ascii_uppercase)
23+
for _ in range(5)]
24+
unique_filename = 'Valid Folder'+''.join(random_chars)
25+
return unique_filename
3526

36-
@with_setup(init)
37-
def test_create_nested_folders():
38-
first_folder = _random_filename()
39-
nested_folder = '{0}/{1}'.format(first_folder, _random_filename())
40-
py.file_ops.mkdirs(nested_folder)
27+
def test_create_folder(self):
28+
try:
29+
py.file_ops.mkdirs(self._random_filename())
30+
except PlotlyRequestError as e:
31+
self.fail('Expected this *not* to fail! Status: {}'
32+
.format(e.status_code))
4133

34+
def test_create_nested_folders(self):
35+
first_folder = self._random_filename()
36+
nested_folder = '{0}/{1}'.format(first_folder, self._random_filename())
37+
try:
38+
py.file_ops.mkdirs(nested_folder)
39+
except PlotlyRequestError as e:
40+
self.fail('Expected this *not* to fail! Status: {}'
41+
.format(e.status_code))
4242

43-
@with_setup(init)
44-
def test_duplicate_folders():
45-
first_folder = _random_filename()
46-
py.file_ops.mkdirs(first_folder)
47-
try:
43+
def test_duplicate_folders(self):
44+
first_folder = self._random_filename()
4845
py.file_ops.mkdirs(first_folder)
49-
except PlotlyRequestError as e:
50-
if e.status_code != 409:
51-
raise e
46+
try:
47+
py.file_ops.mkdirs(first_folder)
48+
except PlotlyRequestError as e:
49+
self.assertTrue(400 <= e.status_code < 500)
50+
else:
51+
self.fail('Expected this to fail!')

plotly/tests/test_optional/test_utils/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def test_pandas_json_encoding():
225225
# Test that data wasn't mutated
226226
assert_series_equal(df['col 1'],
227227
pd.Series([1, 2, 3, dt(2014, 1, 5),
228-
pd.NaT, np.NaN, np.Inf]))
228+
pd.NaT, np.NaN, np.Inf], name='col 1'))
229229

230230
j2 = json.dumps(df.index, cls=utils.PlotlyJSONEncoder)
231231
assert(j2 == '[0, 1, 2, 3, 4, 5, 6]')

0 commit comments

Comments
 (0)