enthought / enthought/traitsui
Bug: The mouse_click function in wx/_interaction_helpers.py do not set focus to current control
- Dominant language
- Python
- Stars
- 306
- Forks
- 99
- PR merge metrics
- No merged PRs in 30d
Description
The mouse_click function in for wx located in traitsui/testing/tester/_ui_tester_registry/wx/_interaction_helpers.py do not set focus to current control. This result in test failures when testing the RangeTextEditor for wx, because
when editing the text part of a range control box and clicking on the OK button will not update the value of the HasTraits class
since the focus will not change in the test-envirionment as exemplified in the following test:
class NumberWithRangeEditor(HasTraits):
"""Dialog containing a RangeEditor in 'spinner' mode for an Int."""
number = Int()
traits_view = View(
Item(label="Range should be 3 to 8. Enter 1, then press OK"),
Item("number", editor=RangeEditor(low=3, high=8, mode="text",
enter_set=True,
auto_set=False)),
buttons=["OK", "Cancel"],
)
class TestRangeEditorText(BaseTestMixin, unittest.TestCase):
def setUp(self):
BaseTestMixin.setUp(self)
def tearDown(self):
BaseTestMixin.tearDown(self)
@requires_toolkit([ToolkitName.qt, ToolkitName.wx])
def test_text_editing(self):
num = NumberWithRangeEditor()
assert num.number == 0
tester = UITester()
with tester.create_ui(num) as ui:
text = tester.find_by_name(ui, "number")
displayed = text.inspect(DisplayedText())
assert displayed == '3'
assert num.number == 3
text.perform(command.KeyClick("Backspace"))
text.perform(command.KeyClick("4"))
displayed = text.inspect(DisplayedText())
assert displayed == '4'
assert num.number == 3
cancel_button = tester.find_by_id(ui, "Cancel")
cancel_button.perform(command.MouseClick())
assert num.number == 4
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in traitsui/testing/tester/_ui_tester_registry/wx/_interaction_helpers.py at mouse_click, then reproduce the behavior with TestRangeEditorText.test_text_editing and the RangeEditor text-editing scenario shown in the issue. Done means clicking the dialog button changes focus, updates the HasTraits value, and the test passes for wx.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- desktop, testing-qa
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100