test_widget_float.py 606 B

12345678910111213141516171819202122
  1. # Copyright (c) Jupyter Development Team.
  2. # Distributed under the terms of the Modified BSD License.
  3. from unittest import TestCase
  4. from traitlets import TraitError
  5. from ipywidgets import FloatSlider
  6. class TestFloatSlider(TestCase):
  7. def test_construction(self):
  8. FloatSlider()
  9. def test_construction_readout_format(self):
  10. slider = FloatSlider(readout_format='$.1f')
  11. assert slider.get_state()['readout_format'] == '$.1f'
  12. def test_construction_invalid_readout_format(self):
  13. with self.assertRaises(TraitError):
  14. FloatSlider(readout_format='broken')