enable.testing module

class enable.testing.EnableTestAssistant[source]

Bases: kiva.testing.KivaTestAssistant

Mixin helper for enable/chaco components.

create_drag_event(**kwargs)[source]

Creates a DragEvent() with the specified attributes.

create_key_press(key, window=None, alt_down=False, control_down=False, shift_down=False)[source]

Creates a KeyEvent for the given Key.

Parameters
  • key (string) – The key of the event

  • window (AbstractWindow, optional) – The enable AbstractWindow to associate with the event. Default is to create a mock class instance.

  • alt_down (boolean, optional) – The key is pressed while alt is down. Default value is False.

  • control_down (boolean, optional) – The key is pressed while control is down. Default value is False.

  • shift_down (boolean, optional) – The key is pressed while shift is down. Default value is False.

Returns

key_event – The enable KEyEvent instance of the desired event ready to be passed to an enable Interactor.

Return type

KeyEvent

create_mock_window()[source]

Creates a Mock class that behaves as an enable Abstract Window.

Returns

window – A mock class instance of an abstract window.

Return type

Mock

create_mouse_event(**kwargs)[source]

Creates a MouseEvent() with the specified attributes.

mouse_dclick(interactor, x, y, button='left', window=None, alt_down=False, control_down=False, shift_down=False)[source]

Send a mouse double-click event to the interactor.

Parameters
  • interactor (Interactor) – The interactor (or subclass) where to dispatch the event.

  • x (float) – The x coordinates of the mouse position

  • y (float) – The y coordinates of the mouse position

  • button ({'left', 'right'}, optional) – The mouse button for which to simulate a press (down) action.

  • window (AbstractWindow, optional) – The enable AbstractWindow to associate with the event. Default is to create a mock class instance. If the window has a mouse owner then that interactor is used.

  • alt_down (boolean, optional) – The button is pressed while alt is down. Default value is False.

  • control_down (boolean, optional) – The button is pressed while control is down. Default value is False.

  • shift_down (boolean, optional) – The button is pressed while shift is down. Default value is False.

Returns

event – The event instance after it has be processed by the interactor.

Return type

MouseEvent

mouse_down(interactor, x, y, button='left', window=None, alt_down=False, control_down=False, shift_down=False)[source]

Send a mouse button down event to the interactor.

Parameters
  • interactor (Interactor) – The interactor (or subclass) where to dispatch the event.

  • x (float) – The x coordinates of the mouse position

  • y (float) – The y coordinates of the mouse position

  • button ({'left', 'right'}, optional) – The mouse button for which to simulate a press (down) action.

  • window (AbstractWindow, optional) – The enable AbstractWindow to associate with the event. Default is to create a mock class instance. If the window has a mouse owner then that interactor is used.

  • alt_down (boolean, optional) – The button is pressed while alt is down. Default value is False.

  • control_down (boolean, optional) – The button is pressed while control is down. Default value is False.

  • shift_down (boolean, optional) – The button is pressed while shift is down. Default value is False.

Returns

event – The event instance after it has be processed by the interactor.

Return type

MouseEvent

mouse_enter(interactor, x, y, window=None, alt_down=False, control_down=False, shift_down=False)[source]

Send a mouse enter event to the interactor.

Parameters
  • interactor (Interactor) – The interactor (or subclass) where to dispatch the event.

  • x (float) – The x coordinates of the mouse position

  • y (float) – The y coordinates of the mouse position

  • window (AbstractWindow, optional) – The enable AbstractWindow to associate with the event. Default is to create a mock class instance. If the window has a mouse owner then that interactor is used.

  • alt_down (boolean, optional) – The button is pressed while alt is down. Default value is False.

  • control_down (boolean, optional) – The button is pressed while control is down. Default value is False.

  • shift_down (boolean, optional) – The button is pressed while shift is down. Default value is False.

Returns

event – The event instance after it has be processed by the interactor.

Return type

MouseEvent

mouse_leave(interactor, x, y, window=None, alt_down=False, control_down=False, shift_down=False)[source]

Send a mouse leave event to the interactor.

Parameters
  • interactor (Interactor) – The interactor (or subclass) where to dispatch the event.

  • x (float) – The x coordinates of the mouse position

  • y (float) – The y coordinates of the mouse position

  • window (AbstractWindow, optional) – The enable AbstractWindow to associate with the event. Default is to create a mock class instance. If the window has a mouse owner then that interactor is used.

  • alt_down (boolean, optional) – The button is pressed while alt is down. Default value is False.

  • control_down (boolean, optional) – The button is pressed while control is down. Default value is False.

  • shift_down (boolean, optional) – The button is pressed while shift is down. Default value is False.

Returns

event – The event instance after it has be processed by the interactor.

Return type

MouseEvent

mouse_move(interactor, x, y, window=None, alt_down=False, control_down=False, shift_down=False, left_down=<undefined>, middle_down=<undefined>, right_down=<undefined>)[source]

Send a mouse move event to the interactor.

Parameters
  • interactor (Interactor) – The interactor (or subclass) where to dispatch the event.

  • x (float) – The x coordinates of the mouse position

  • y (float) – The y coordinates of the mouse position

  • window (AbstractWindow, optional) – The enable AbstractWindow to associate with the event. Default is to create a mock class instance. If the window has a mouse owner then that interactor is used. If a non-Mocked window is used, then either the test should not require the use of get_pointer_position() or should use a mock for the method.

  • alt_down (boolean, optional) – The mouse is moved while alt is down. Default value is False.

  • control_down (boolean, optional) – The mouse is moved while control is down. Default value is False.

  • shift_down (boolean, optional) – The mouse is moved while shift is down. Default value is False.

  • left_down (boolean, optional) – The mouse is moved while left is down. Default value is Undefined.

  • middle_down (boolean, optional) – The mouse is moved while middle is down. Default value is Undefined.

  • right_down (boolean, optional) – The mouse is moved while right is down. Default value is Undefined.

Returns

event – The event instance after it has be processed by the interactor.

Return type

MouseEvent

mouse_up(interactor, x, y, button='left', window=None, alt_down=False, control_down=False, shift_down=False)[source]

Send a mouse button up event to the interactor.

Parameters
  • interactor (Interactor) – The interactor (or subclass) where to dispatch the event.

  • x (float) – The x coordinates of the mouse position

  • y (float) – The y coordinates of the mouse position

  • button ({'left', 'right'}, optional) – The mouse button for which to simulate a release (up) action.

  • window (AbstractWindow, optional) – The enable AbstractWindow to associate with the event. Default is to create a mock class instance. If the window has a mouse owner then that interactor is used.

  • alt_down (boolean, optional) – The button is pressed while alt is down. Default value is False.

  • control_down (boolean, optional) – The button is pressed while control is down. Default value is False.

  • shift_down (boolean, optional) – The button is pressed while shift is down. Default value is False.

Returns

event – The event instance after it has be processed by the interactor.

Return type

MouseEvent

press_move_release(interactor, points, window=None, alt_down=False, control_down=False, shift_down=False)[source]

Simulate the action of left click pressing, dragging and releasing the mouse.

Parameters
  • interactor (enable interactor object) – This is object where the mouse events will be dispatched to.

  • points (A list of x,y tuple) – The x,y positions of the three event sections. The first tuple will be sent with a left-down event and the last will be sent with a left-up. All the other events in the list will be sent using a mouse-move event.

  • window (AbstractWindow, optional) – The enable AbstractWindow to associate with the event. Default is to create a mock class instance. If the window has a mouse owner then that interactor is used. If a non-Mocked window is used, then either the test should not require the use of get_pointer_position() or should use a mock for the method.

  • alt_down (boolean, optional) – The button is pressed while alt is down. Default value is False.

  • control_down (boolean, optional) – The button is pressed while control is down. Default value is False.

  • shift_down (boolean, optional) – The button is pressed while shift is down. Default value is False.

send_drag_leave(interactor, x, y, window=None)[source]

Sent a drag_leave event to the interactor.

Parameters
  • interactor (Interactor) – The interactor (or subclass) where to dispatch the event.

  • x (float) – The x coordinates of the mouse position

  • y (float) – The y coordinates of the mouse position

  • window (AbstractWindow, optional) – The enable AbstractWindow to associate with the event. Default is to create a mock class instance. If the window has a mouse owner then that interactor is used.

Returns

event – The event instance after it has be processed by the interactor.

Return type

KeyEvent

send_drag_over(interactor, x, y, obj, window=None)[source]

Sent a drag_over event to the interactor.

Parameters
  • interactor (Interactor) – The interactor (or subclass) where to dispatch the event.

  • x (float) – The x coordinates of the mouse position

  • y (float) – The y coordinates of the mouse position

  • obj (object) – The object(s) being dragged or dropped

  • window (AbstractWindow, optional) – The enable AbstractWindow to associate with the event. Default is to create a mock class instance. If the window has a mouse owner then that interactor is used.

Returns

event – The event instance after it has be processed by the interactor.

Return type

KeyEvent

send_dropped_on(interactor, x, y, obj, window=None)[source]

Sent a dropped_on event to the interactor.

Parameters
  • interactor (Interactor) – The interactor (or subclass) where to dispatch the event.

  • x (float) – The x coordinates of the mouse position

  • y (float) – The y coordinates of the mouse position

  • obj (object) – The object(s) being dragged or dropped

  • window (AbstractWindow, optional) – The enable AbstractWindow to associate with the event. Default is to create a mock class instance. If the window has a mouse owner then that interactor is used.

Returns

event – The event instance after it has be processed by the interactor.

Return type

KeyEvent

send_key(interactor, key, window=None)[source]

Sent a key press event to the interactor.

Parameters
  • interactor (Interactor) – The interactor (or subclass) where to dispatch the event.

  • key (string) – The key press to simulate.

  • window (AbstractWindow, optional) – The enable AbstractWindow to associate with the event. Default is to create a mock class instance. If the window has a focus owner then that interactor is used.

Returns

event – The event instance after it has be processed by the interactor.

Return type

KeyEvent