Skip to content

Commit 66b6782

Browse files
committed
Added tests for colorscales specified as a string
Added tests checking that a colorscale specified as a string is returned correctly. Previously it had been returned as a tuple of 1-tuples. e.g. "Viridis" -> (('V',), ('i',), ('r',), ('i',), ('d',), ('i',), ('s',)). Catches plotly#1087.
1 parent d670bb0 commit 66b6782

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

_plotly_utils/tests/validators/test_colorscale_validator.py

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ def test_acceptance_named(named_colorscale, validator: ColorscaleValidator):
2626
# Uppercase
2727
assert (validator.validate_coerce(named_colorscale.upper()) ==
2828
named_colorscale.upper())
29+
30+
assert validator.present(named_colorscale) == named_colorscale
2931

3032
# ### Acceptance as array ###
3133
@pytest.mark.parametrize('val', [

plotly/tests/test_core/test_graph_objs/test_properties_validated.py

+10
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,16 @@ def test_present_colorscale(self):
102102
# Presented as tuple of tuples
103103
self.assertEqual(self.scatter.marker.colorscale,
104104
((0, 'red'), (1, 'green')))
105+
106+
def test_present_colorscale_str(self):
107+
self.assertIsNone(self.scatter.marker.colorscale)
108+
109+
# Assign string
110+
self.scatter.marker.colorscale = "Viridis"
111+
112+
# Presented as a string
113+
self.assertEqual(self.scatter.marker.colorscale,
114+
"Viridis")
105115

106116

107117
class TestPropertyIterContains(TestCase):

0 commit comments

Comments
 (0)