def test_floating_point_wait_raises_error(): # A floating point value should reaise a TraitletError event_widget = Event() with pytest.raises(traitlets.traitlets.TraitError) as e: event_widget.wait = 15.0 assert "'wait' trait of an Event instance" in str(e)
def test_negative_wait_raises_error(): # negative wait should raise an error. event_widget = Event() with pytest.raises(ValueError) as e: event_widget.wait = -20 assert 'wait must be set to a non-negative integer. ' in str(e)
def test_setting_wait_with_debounce_set_preserves_debounce(slow_method): # If debounce is set but wait is zero and wait is then set to something # non-zero then throttle_or_debounce should still stay debounce. event_widget = Event() event_widget.throttle_or_debounce = slow_method # Make sure wait is currently zero... assert event_widget.wait == 0 # This shouldn't change throttle or debounce event_widget.wait = 20 assert event_widget.throttle_or_debounce == slow_method
def test_setting_wait_with_no_throttle_or_debounce(): # If wait is set to something non-zero AND neither throttle # nor debounce has been set then it should be set to # throttle. event_widget = Event() # Make sure throttle_or_debounce is not set... assert not event_widget.throttle_or_debounce # ...and that wait is currently zero assert event_widget.wait == 0 # This implicitly sets throttle_or_debounce event_widget.wait = 20 assert event_widget.throttle_or_debounce == 'throttle'