From 8a0233bb166e3c1936a51ae6df053f36a0952bb0 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Wed, 2 Sep 2020 09:07:57 -0500 Subject: [PATCH 01/12] explicitly handle a KeyClick('Backspace') --- traitsui/testing/tester/wx/helpers.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/traitsui/testing/tester/wx/helpers.py b/traitsui/testing/tester/wx/helpers.py index d0ec801f4..78b25f8ae 100644 --- a/traitsui/testing/tester/wx/helpers.py +++ b/traitsui/testing/tester/wx/helpers.py @@ -117,6 +117,10 @@ def key_click_text_ctrl(control, interaction, delay): wx.MilliSleep(delay) event = wx.CommandEvent(wx.EVT_TEXT_ENTER.typeId, control.GetId()) control.ProcessEvent(event) + elif interaction.key == "Backspace": + wx.MilliSleep(delay) + pos = control.GetInsertionPoint() + control.Remove(max(0, pos - 1), pos) else: key_click(control, interaction.key, delay) From c30b8aa8bddc6fbc36c3628841d94c7d50ed6d3e Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Wed, 2 Sep 2020 10:23:09 -0500 Subject: [PATCH 02/12] making same change to KeyClick that was just made to KeySequence --- traitsui/testing/tester/wx/helpers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/traitsui/testing/tester/wx/helpers.py b/traitsui/testing/tester/wx/helpers.py index 78b25f8ae..11ad8b98f 100644 --- a/traitsui/testing/tester/wx/helpers.py +++ b/traitsui/testing/tester/wx/helpers.py @@ -122,7 +122,9 @@ def key_click_text_ctrl(control, interaction, delay): pos = control.GetInsertionPoint() control.Remove(max(0, pos - 1), pos) else: - key_click(control, interaction.key, delay) + check_key_compat(interaction.key) + wx.MilliSleep(delay) + control.WriteText(interaction.key) def key_sequence_text_ctrl(control, interaction, delay): From 2c3ce2610fcc94128d9ce79fc5a9ae1677b9dc8e Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Wed, 2 Sep 2020 10:27:01 -0500 Subject: [PATCH 03/12] adding note to key_click function docstring that it currently is not working on windows so it is unused for now --- traitsui/testing/tester/wx/helpers.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/traitsui/testing/tester/wx/helpers.py b/traitsui/testing/tester/wx/helpers.py index 11ad8b98f..5e9054b73 100644 --- a/traitsui/testing/tester/wx/helpers.py +++ b/traitsui/testing/tester/wx/helpers.py @@ -30,6 +30,11 @@ def key_click(widget, key, delay=0): Note: modifiers (e.g. Shift, Alt, etc. are not currently supported) delay : int Time delay (in ms) in which the key click will be performed. + + Notes + ----- + This function is currently unused due to issue on Windows + see traitsui issues #1182 and #1183 """ mapping = {name: event for event, name in _KEY_MAP.items()} From 72e46e34aa75648843ce37a4097f9bd2be4a12bc Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Wed, 2 Sep 2020 11:42:08 -0500 Subject: [PATCH 04/12] have wx default to having insertion point start at rightmost end of text for range editor --- traitsui/testing/tester/wx/helpers.py | 3 +++ .../testing/tester/wx/implementation/range_editor.py | 11 +++++++++-- traitsui/tests/editors/test_range_editor.py | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/traitsui/testing/tester/wx/helpers.py b/traitsui/testing/tester/wx/helpers.py index 5e9054b73..d76b81ad7 100644 --- a/traitsui/testing/tester/wx/helpers.py +++ b/traitsui/testing/tester/wx/helpers.py @@ -115,7 +115,10 @@ def key_click_text_ctrl(control, interaction, delay): if not control.IsEditable(): raise Disabled("{!r} is disabled.".format(control)) if not control.HasFocus(): + # setFocus resets the InsertionPoint to be 0. We want to preserve it + temp = control.GetInsertionPoint() control.SetFocus() + control.SetInsertionPoint(temp) # EmulateKeyPress in key_click seems to not be handling "Enter" # correctly. if interaction.key == "Enter": diff --git a/traitsui/testing/tester/wx/implementation/range_editor.py b/traitsui/testing/tester/wx/implementation/range_editor.py index cf1a29119..413450ad2 100644 --- a/traitsui/testing/tester/wx/implementation/range_editor.py +++ b/traitsui/testing/tester/wx/implementation/range_editor.py @@ -33,7 +33,9 @@ def resolve_location_slider(wrapper, location): The location we are looking to resolve. """ if location == locator.WidgetType.textbox: - return LocatedTextbox(textbox=wrapper.target.control.text) + textbox = wrapper.target.control.text + textbox.SetInsertionPoint(textbox.GetLastPosition()+1) + return LocatedTextbox(textbox=textbox) if location in [locator.WidgetType.slider]: raise NotImplementedError( f"Logic for interacting with the {location}" @@ -60,7 +62,12 @@ def resolve_location_range_text(wrapper, location): """ if location == locator.WidgetType.textbox: - return LocatedTextbox(textbox=wrapper.target.control) + textbox = wrapper.target.control + # wx defaults to having insertion point start at 0 + # for consistent behavior accross toolkits, we set this default to + # be the right most point of the textbox + textbox.SetInsertionPoint(textbox.GetLastPosition()+1) + return LocatedTextbox(textbox=textbox) raise ValueError( f"Unable to resolve {location} on {wrapper.target}." " Currently supported: {locator.WidgetType.textbox}" diff --git a/traitsui/tests/editors/test_range_editor.py b/traitsui/tests/editors/test_range_editor.py index e03284b76..b317eacce 100644 --- a/traitsui/tests/editors/test_range_editor.py +++ b/traitsui/tests/editors/test_range_editor.py @@ -58,7 +58,7 @@ def check_set_with_text(self, mode): editor=RangeEditor(low=1, high=12, mode=mode) ) ) - tester = UITester() + tester = UITester(delay=500) with tester.create_ui(model, dict(view=view)) as ui: number_field = tester.find_by_name(ui, "value") text = number_field.locate(locator.WidgetType.textbox) From b6eb70b5ab68a8367e826fb7b2aa1cd7c8d6e6ad Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Wed, 2 Sep 2020 11:43:28 -0500 Subject: [PATCH 05/12] removing delay in test --- traitsui/tests/editors/test_range_editor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/traitsui/tests/editors/test_range_editor.py b/traitsui/tests/editors/test_range_editor.py index b317eacce..e03284b76 100644 --- a/traitsui/tests/editors/test_range_editor.py +++ b/traitsui/tests/editors/test_range_editor.py @@ -58,7 +58,7 @@ def check_set_with_text(self, mode): editor=RangeEditor(low=1, high=12, mode=mode) ) ) - tester = UITester(delay=500) + tester = UITester() with tester.create_ui(model, dict(view=view)) as ui: number_field = tester.find_by_name(ui, "value") text = number_field.locate(locator.WidgetType.textbox) From 56d63c6187eea8814bc475e1322cf7eb3a5a8ead Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Wed, 2 Sep 2020 11:57:35 -0500 Subject: [PATCH 06/12] avoiding invalid state in text style range editor test --- traitsui/tests/editors/test_range_editor.py | 23 ++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/traitsui/tests/editors/test_range_editor.py b/traitsui/tests/editors/test_range_editor.py index e03284b76..7ee23f859 100644 --- a/traitsui/tests/editors/test_range_editor.py +++ b/traitsui/tests/editors/test_range_editor.py @@ -80,4 +80,25 @@ def test_log_range_slider_editor_set_with_text(self): return self.check_set_with_text(mode='logslider') def test_range_text_editor_set_with_text(self): - return self.check_set_with_text(mode='text') + model = RangeModel() + view = View( + Item( + "value", + editor=RangeEditor(low=1, high=12, mode='text') + ) + ) + tester = UITester() + with tester.create_ui(model, dict(view=view)) as ui: + number_field = tester.find_by_name(ui, "value") + text = number_field.locate(locator.WidgetType.textbox) + text.perform(command.KeyClick("1")) + text.perform(command.KeyClick("Enter")) + displayed = text.inspect(query.DisplayedText()) + self.assertEqual(model.value, 11) + self.assertEqual(displayed, str(model.value)) + text.perform(command.KeyClick("Backspace")) + text.perform(command.KeyClick("0")) + text.perform(command.KeyClick("Enter")) + displayed = text.inspect(query.DisplayedText()) + self.assertEqual(model.value, 10) + self.assertEqual(displayed, str(model.value)) From 34b5a8c986293fedb6ff44bfc366a437149c2a40 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Wed, 2 Sep 2020 12:00:10 -0500 Subject: [PATCH 07/12] adding comments --- traitsui/testing/tester/wx/implementation/range_editor.py | 3 +++ traitsui/tests/editors/test_range_editor.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/traitsui/testing/tester/wx/implementation/range_editor.py b/traitsui/testing/tester/wx/implementation/range_editor.py index 413450ad2..7213c0c73 100644 --- a/traitsui/testing/tester/wx/implementation/range_editor.py +++ b/traitsui/testing/tester/wx/implementation/range_editor.py @@ -34,6 +34,9 @@ def resolve_location_slider(wrapper, location): """ if location == locator.WidgetType.textbox: textbox = wrapper.target.control.text + # wx defaults to having insertion point start at 0 + # for consistent behavior accross toolkits, we set this default to + # be the right most point of the textbox textbox.SetInsertionPoint(textbox.GetLastPosition()+1) return LocatedTextbox(textbox=textbox) if location in [locator.WidgetType.slider]: diff --git a/traitsui/tests/editors/test_range_editor.py b/traitsui/tests/editors/test_range_editor.py index 7ee23f859..090afdfdb 100644 --- a/traitsui/tests/editors/test_range_editor.py +++ b/traitsui/tests/editors/test_range_editor.py @@ -80,6 +80,8 @@ def test_log_range_slider_editor_set_with_text(self): return self.check_set_with_text(mode='logslider') def test_range_text_editor_set_with_text(self): + # this test is seperate to avoid an invalid state after deleting + # contents of textbox model = RangeModel() view = View( Item( From 15370effff16ee80068ca438e5c6919c8a6582e0 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Wed, 2 Sep 2020 12:08:20 -0500 Subject: [PATCH 08/12] making previous change a wx specific test --- traitsui/tests/editors/test_range_editor.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/traitsui/tests/editors/test_range_editor.py b/traitsui/tests/editors/test_range_editor.py index 090afdfdb..b71562fe2 100644 --- a/traitsui/tests/editors/test_range_editor.py +++ b/traitsui/tests/editors/test_range_editor.py @@ -79,7 +79,12 @@ def test_large_range_slider_editor_set_with_text(self): def test_log_range_slider_editor_set_with_text(self): return self.check_set_with_text(mode='logslider') + @requires_toolkit([ToolkitName.qt]) def test_range_text_editor_set_with_text(self): + return self.check_set_with_text(mode='text') + + @requires_toolkit([ToolkitName.wx]) + def test_range_text_editor_set_with_text_wx(self): # this test is seperate to avoid an invalid state after deleting # contents of textbox model = RangeModel() From f4b85c32495318db65d9ee9089ee44f52fb18749 Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Thu, 3 Sep 2020 09:17:19 -0500 Subject: [PATCH 09/12] making suggested changes --- traitsui/testing/tester/wx/helpers.py | 48 +------------ .../tester/wx/implementation/range_editor.py | 8 --- traitsui/tests/editors/test_range_editor.py | 67 +++++++++++-------- 3 files changed, 39 insertions(+), 84 deletions(-) diff --git a/traitsui/testing/tester/wx/helpers.py b/traitsui/testing/tester/wx/helpers.py index d76b81ad7..d51754972 100644 --- a/traitsui/testing/tester/wx/helpers.py +++ b/traitsui/testing/tester/wx/helpers.py @@ -16,48 +16,6 @@ from traitsui.wx.key_event_to_name import key_map as _KEY_MAP -def key_click(widget, key, delay=0): - """ Performs a key click of the given key on the given widget after - a delay. - - Parameters - ---------- - widget : wx.TextCtrl - The wx Object to be key cliecked to. - key : str - Standardized (pyface) name for a keyboard event. - e.g. "Enter", "Tab", "Space", "0", "1", "A", ... - Note: modifiers (e.g. Shift, Alt, etc. are not currently supported) - delay : int - Time delay (in ms) in which the key click will be performed. - - Notes - ----- - This function is currently unused due to issue on Windows - see traitsui issues #1182 and #1183 - """ - - mapping = {name: event for event, name in _KEY_MAP.items()} - if key not in mapping: - try: - KEY = ord(key) - except [TypeError, ValueError]: - raise ValueError( - "Unknown key {!r}. Expected one of these: {!r}, or a unicode character".format( # noqa - key, sorted(mapping) - )) - else: - wx.MilliSleep(delay) - key_event = wx.KeyEvent(wx.wxEVT_CHAR) - key_event.SetUnicodeKey(KEY) - widget.EmulateKeyPress(key_event) - else: - wx.MilliSleep(delay) - key_event = wx.KeyEvent(wx.wxEVT_CHAR) - key_event.SetKeyCode(mapping[key]) - widget.EmulateKeyPress(key_event) - - def mouse_click_button(control, delay): """ Performs a mouce click on a wx button. @@ -115,12 +73,8 @@ def key_click_text_ctrl(control, interaction, delay): if not control.IsEditable(): raise Disabled("{!r} is disabled.".format(control)) if not control.HasFocus(): - # setFocus resets the InsertionPoint to be 0. We want to preserve it - temp = control.GetInsertionPoint() control.SetFocus() - control.SetInsertionPoint(temp) - # EmulateKeyPress in key_click seems to not be handling "Enter" - # correctly. + control.SetInsertionPointEnd() if interaction.key == "Enter": wx.MilliSleep(delay) event = wx.CommandEvent(wx.EVT_TEXT_ENTER.typeId, control.GetId()) diff --git a/traitsui/testing/tester/wx/implementation/range_editor.py b/traitsui/testing/tester/wx/implementation/range_editor.py index 7213c0c73..09e644314 100644 --- a/traitsui/testing/tester/wx/implementation/range_editor.py +++ b/traitsui/testing/tester/wx/implementation/range_editor.py @@ -34,10 +34,6 @@ def resolve_location_slider(wrapper, location): """ if location == locator.WidgetType.textbox: textbox = wrapper.target.control.text - # wx defaults to having insertion point start at 0 - # for consistent behavior accross toolkits, we set this default to - # be the right most point of the textbox - textbox.SetInsertionPoint(textbox.GetLastPosition()+1) return LocatedTextbox(textbox=textbox) if location in [locator.WidgetType.slider]: raise NotImplementedError( @@ -66,10 +62,6 @@ def resolve_location_range_text(wrapper, location): if location == locator.WidgetType.textbox: textbox = wrapper.target.control - # wx defaults to having insertion point start at 0 - # for consistent behavior accross toolkits, we set this default to - # be the right most point of the textbox - textbox.SetInsertionPoint(textbox.GetLastPosition()+1) return LocatedTextbox(textbox=textbox) raise ValueError( f"Unable to resolve {location} on {wrapper.target}." diff --git a/traitsui/tests/editors/test_range_editor.py b/traitsui/tests/editors/test_range_editor.py index b71562fe2..2e4fea605 100644 --- a/traitsui/tests/editors/test_range_editor.py +++ b/traitsui/tests/editors/test_range_editor.py @@ -12,7 +12,7 @@ class RangeModel(HasTraits): - value = Int() + value = Int(1) @requires_toolkit([ToolkitName.qt, ToolkitName.wx]) @@ -50,7 +50,7 @@ def test_simple_editor_format_func(self): def test_custom_editor_format_func(self): self.check_range_enum_editor_format_func("custom") - def check_set_with_text(self, mode): + def check_set_with_text_valid(self, mode): model = RangeModel() view = View( Item( @@ -60,52 +60,61 @@ def check_set_with_text(self, mode): ) tester = UITester() with tester.create_ui(model, dict(view=view)) as ui: + # sanity check + self.assertEqual(model.value, 1) number_field = tester.find_by_name(ui, "value") text = number_field.locate(locator.WidgetType.textbox) - for _ in range(5): - text.perform(command.KeyClick("Backspace")) - text.perform(command.KeyClick("4")) + text.perform(command.KeyClick("0")) text.perform(command.KeyClick("Enter")) displayed = text.inspect(query.DisplayedText()) - self.assertEqual(model.value, 4) + self.assertEqual(model.value, 10) self.assertEqual(displayed, str(model.value)) - def test_simple_slider_editor_set_with_text(self): - return self.check_set_with_text(mode='slider') + def test_simple_slider_editor_set_with_text_valid(self): + return self.check_set_with_text_valid(mode='slider') - def test_large_range_slider_editor_set_with_text(self): - return self.check_set_with_text(mode='xslider') + def test_large_range_slider_editor_set_with_text_valid(self): + return self.check_set_with_text_valid(mode='xslider') - def test_log_range_slider_editor_set_with_text(self): - return self.check_set_with_text(mode='logslider') + def test_log_range_slider_editor_set_with_text_valid(self): + return self.check_set_with_text_valid(mode='logslider') - @requires_toolkit([ToolkitName.qt]) - def test_range_text_editor_set_with_text(self): - return self.check_set_with_text(mode='text') - - @requires_toolkit([ToolkitName.wx]) - def test_range_text_editor_set_with_text_wx(self): - # this test is seperate to avoid an invalid state after deleting - # contents of textbox + def test_range_text_editor_set_with_text_valid(self): + return self.check_set_with_text_valid(mode='text') + + def check_set_with_text_after_empty(self, mode): model = RangeModel() view = View( Item( "value", - editor=RangeEditor(low=1, high=12, mode='text') + editor=RangeEditor(low=1, high=12, mode=mode) ) ) tester = UITester() with tester.create_ui(model, dict(view=view)) as ui: number_field = tester.find_by_name(ui, "value") text = number_field.locate(locator.WidgetType.textbox) - text.perform(command.KeyClick("1")) - text.perform(command.KeyClick("Enter")) - displayed = text.inspect(query.DisplayedText()) - self.assertEqual(model.value, 11) - self.assertEqual(displayed, str(model.value)) - text.perform(command.KeyClick("Backspace")) - text.perform(command.KeyClick("0")) + # Delete all contents of textbox + for _ in range(5): + text.perform(command.KeyClick("Backspace")) + text.perform(command.KeyClick("4")) text.perform(command.KeyClick("Enter")) displayed = text.inspect(query.DisplayedText()) - self.assertEqual(model.value, 10) + self.assertEqual(model.value, 4) self.assertEqual(displayed, str(model.value)) + + def test_simple_slider_editor_set_with_text_after_empty(self): + return self.check_set_with_text_after_empty(mode='slider') + + def test_large_range_slider_editor_set_with_text_after_empty(self): + return self.check_set_with_text_after_empty(mode='xslider') + + def test_log_range_slider_editor_set_with_text_after_empty(self): + return self.check_set_with_text_after_empty(mode='logslider') + + # on wx the text style editor gives an error whenever the textbox + # is empty, even if enter has not been pressed. + @requires_toolkit([ToolkitName.qt]) + def test_range_text_editor_set_with_text_after_empty(self): + return self.check_set_with_text_after_empty(mode='text') + From 37089120117955df9104c67f2e175067d3fc96bd Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Thu, 3 Sep 2020 09:29:45 -0500 Subject: [PATCH 10/12] undoing unneeded change --- traitsui/testing/tester/wx/implementation/range_editor.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/traitsui/testing/tester/wx/implementation/range_editor.py b/traitsui/testing/tester/wx/implementation/range_editor.py index 09e644314..cf1a29119 100644 --- a/traitsui/testing/tester/wx/implementation/range_editor.py +++ b/traitsui/testing/tester/wx/implementation/range_editor.py @@ -33,8 +33,7 @@ def resolve_location_slider(wrapper, location): The location we are looking to resolve. """ if location == locator.WidgetType.textbox: - textbox = wrapper.target.control.text - return LocatedTextbox(textbox=textbox) + return LocatedTextbox(textbox=wrapper.target.control.text) if location in [locator.WidgetType.slider]: raise NotImplementedError( f"Logic for interacting with the {location}" @@ -61,8 +60,7 @@ def resolve_location_range_text(wrapper, location): """ if location == locator.WidgetType.textbox: - textbox = wrapper.target.control - return LocatedTextbox(textbox=textbox) + return LocatedTextbox(textbox=wrapper.target.control) raise ValueError( f"Unable to resolve {location} on {wrapper.target}." " Currently supported: {locator.WidgetType.textbox}" From 03059c0ff5c0d89b7ea00eb92477c74905d43c5d Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Thu, 3 Sep 2020 11:05:53 -0500 Subject: [PATCH 11/12] fix test failure on wx/windows with RangeTextEditor --- traitsui/tests/editors/test_range_editor.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/traitsui/tests/editors/test_range_editor.py b/traitsui/tests/editors/test_range_editor.py index 2e4fea605..c24efe140 100644 --- a/traitsui/tests/editors/test_range_editor.py +++ b/traitsui/tests/editors/test_range_editor.py @@ -1,3 +1,4 @@ +import platform import unittest from traits.api import HasTraits, Int @@ -5,10 +6,12 @@ from traitsui.testing.tester import command, locator, query from traitsui.testing.tester.ui_tester import UITester from traitsui.tests._tools import ( + is_wx, requires_toolkit, ToolkitName, ) +is_windows = platform.system() == "Windows" class RangeModel(HasTraits): @@ -64,6 +67,11 @@ def check_set_with_text_valid(self, mode): self.assertEqual(model.value, 1) number_field = tester.find_by_name(ui, "value") text = number_field.locate(locator.WidgetType.textbox) + if is_windows and is_wx() and mode=='text': + # For RangeTextEditor on wx and windows, the textbox + # automatically gets focus and the full content is selected. + # Insertion point is moved to keep the test consistent + text.target.textbox.SetInsertionPointEnd() text.perform(command.KeyClick("0")) text.perform(command.KeyClick("Enter")) displayed = text.inspect(query.DisplayedText()) From a98514d680ab708af1fccad329354b9f2164a63f Mon Sep 17 00:00:00 2001 From: Aaron Ayres Date: Thu, 3 Sep 2020 11:29:20 -0500 Subject: [PATCH 12/12] flake8 --- traitsui/testing/tester/wx/helpers.py | 1 - traitsui/tests/editors/test_range_editor.py | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/traitsui/testing/tester/wx/helpers.py b/traitsui/testing/tester/wx/helpers.py index d51754972..e4a6f3af1 100644 --- a/traitsui/testing/tester/wx/helpers.py +++ b/traitsui/testing/tester/wx/helpers.py @@ -13,7 +13,6 @@ from traitsui.testing.tester.compat import check_key_compat from traitsui.testing.tester.exceptions import Disabled -from traitsui.wx.key_event_to_name import key_map as _KEY_MAP def mouse_click_button(control, delay): diff --git a/traitsui/tests/editors/test_range_editor.py b/traitsui/tests/editors/test_range_editor.py index c24efe140..59ad76ab9 100644 --- a/traitsui/tests/editors/test_range_editor.py +++ b/traitsui/tests/editors/test_range_editor.py @@ -13,6 +13,7 @@ is_windows = platform.system() == "Windows" + class RangeModel(HasTraits): value = Int(1) @@ -67,10 +68,10 @@ def check_set_with_text_valid(self, mode): self.assertEqual(model.value, 1) number_field = tester.find_by_name(ui, "value") text = number_field.locate(locator.WidgetType.textbox) - if is_windows and is_wx() and mode=='text': + if is_windows and is_wx() and mode == 'text': # For RangeTextEditor on wx and windows, the textbox # automatically gets focus and the full content is selected. - # Insertion point is moved to keep the test consistent + # Insertion point is moved to keep the test consistent text.target.textbox.SetInsertionPointEnd() text.perform(command.KeyClick("0")) text.perform(command.KeyClick("Enter")) @@ -121,8 +122,7 @@ def test_log_range_slider_editor_set_with_text_after_empty(self): return self.check_set_with_text_after_empty(mode='logslider') # on wx the text style editor gives an error whenever the textbox - # is empty, even if enter has not been pressed. + # is empty, even if enter has not been pressed. @requires_toolkit([ToolkitName.qt]) def test_range_text_editor_set_with_text_after_empty(self): return self.check_set_with_text_after_empty(mode='text') -