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

Skip to content

Commit b95cc89

Browse files
committed
stopgap: Replace validation exceptions with warnings
1 parent 0f699d4 commit b95cc89

File tree

3 files changed

+18
-22
lines changed

3 files changed

+18
-22
lines changed

plotly/tests/test_core/test_graph_objs/test_annotations.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
77
"""
88
from __future__ import absolute_import
9+
import warnings
910

1011
from nose.tools import raises
1112
from plotly.graph_objs import *
@@ -34,14 +35,10 @@ def test_dict_instantiation():
3435
Annotations([{'text': 'annotation text'}])
3536

3637

37-
@raises(PlotlyDictKeyError)
3838
def test_dict_instantiation_key_error():
39-
print(Annotations([{'not-a-key': 'anything'}]))
40-
41-
42-
@raises(PlotlyDictValueError)
43-
def test_dict_instantiation_key_error():
44-
print(Annotations([{'font': 'not-a-dict'}]))
39+
with warnings.catch_warnings(True) as w:
40+
print(Annotations([{'not-a-key': 'anything'}]))
41+
assert(len(w) > 1)
4542

4643

4744
@raises(PlotlyListEntryError)
@@ -73,9 +70,9 @@ def test_validate():
7370
annotations.validate()
7471

7572

76-
@raises(PlotlyDictKeyError)
7773
def test_validate_error():
7874
annotations = Annotations()
7975
annotations.append({'not-a-key': 'anything'})
80-
annotations.validate()
81-
76+
with warnings.catch_warnings(True) as w:
77+
annotations.validate()
78+
assert len(w) > 1

plotly/tests/test_core/test_graph_objs/test_data.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
77
"""
88
from __future__ import absolute_import
9+
import warnings
910

1011
from nose.tools import raises
1112
from plotly.graph_objs import *
@@ -38,14 +39,10 @@ def test_dict_instantiation():
3839
Data([{'type': 'scatter'}])
3940

4041

41-
@raises(PlotlyDictKeyError)
4242
def test_dict_instantiation_key_error():
43-
print(Data([{'not-a-key': 'anything'}]))
44-
45-
46-
@raises(PlotlyDictValueError)
47-
def test_dict_instantiation_key_error():
48-
print(Data([{'marker': 'not-a-dict'}]))
43+
with warnings.catch_warnings(True) as w:
44+
print(Data([{'not-a-key': 'anything'}]))
45+
assert len(w) > 1
4946

5047

5148
@raises(PlotlyDataTypeError)
@@ -82,9 +79,9 @@ def test_validate():
8279
data.validate()
8380

8481

85-
@raises(PlotlyDictKeyError)
8682
def test_validate_error():
8783
data = Data()
8884
data.append({'not-a-key': 'anything'})
89-
data.validate()
90-
85+
with warnings.catch_warnings(True) as w:
86+
data.validate()
87+
assert len(w) > 1

plotly/tests/test_core/test_graph_objs/test_error_bars.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
77
"""
88
from __future__ import absolute_import
9+
import warnings
910

1011
from nose.tools import raises
1112
from plotly.graph_objs import *
@@ -46,6 +47,7 @@ def test_instantiate_error_y():
4647
width=5)
4748

4849

49-
@raises(PlotlyDictKeyError)
5050
def test_key_error():
51-
ErrorX(value=0.1, typ='percent', color='red')
51+
with warnings.catch_warnings(True) as w:
52+
ErrorX(value=0.1, typ='percent', color='red')
53+
assert len(w) > 1

0 commit comments

Comments
 (0)