Skip to content

Commit

Permalink
Added tests for colorscales specified as a string
Browse files Browse the repository at this point in the history
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 #1087.
  • Loading branch information
ivirshup committed Aug 3, 2018
1 parent d670bb0 commit 66b6782
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions _plotly_utils/tests/validators/test_colorscale_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def test_acceptance_named(named_colorscale, validator: ColorscaleValidator):
# Uppercase
assert (validator.validate_coerce(named_colorscale.upper()) ==
named_colorscale.upper())

assert validator.present(named_colorscale) == named_colorscale

# ### Acceptance as array ###
@pytest.mark.parametrize('val', [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ def test_present_colorscale(self):
# Presented as tuple of tuples
self.assertEqual(self.scatter.marker.colorscale,
((0, 'red'), (1, 'green')))

def test_present_colorscale_str(self):
self.assertIsNone(self.scatter.marker.colorscale)

# Assign string
self.scatter.marker.colorscale = "Viridis"

# Presented as a string
self.assertEqual(self.scatter.marker.colorscale,
"Viridis")


class TestPropertyIterContains(TestCase):
Expand Down

0 comments on commit 66b6782

Please sign in to comment.