Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_extended_edit_goto_sol():
extended_edit = ExtendedEdit(None)
extended_edit.set_edit_text(BASE_STRING)
extended_edit.edit_pos = 9
extended_edit.keypress(10, 'ctrl a')
assert extended_edit.edit_pos == 0
assert extended_edit.get_edit_text() == BASE_STRING
extended_edit.set_edit_text(BASE_STRING)
extended_edit.edit_pos = 23
extended_edit.keypress(10, 'ctrl a')
assert extended_edit.edit_pos == 21
assert extended_edit.get_edit_text() == BASE_STRING
def test_extended_edit_delete_word():
extended_edit = ExtendedEdit(None)
extended_edit.set_edit_text(BASE_STRING)
extended_edit.edit_pos = 9
extended_edit.keypress(10, 'ctrl w')
assert extended_edit.edit_pos == 4
assert extended_edit.get_edit_text() == 'The fox bla bla\n@ät'
extended_edit.set_edit_text('The-lazy-fox-bla-bla\n@ät')
extended_edit.edit_pos = 8
extended_edit.keypress(10, 'ctrl w')
assert extended_edit.edit_pos == 4
assert extended_edit.get_edit_text() == 'The--fox-bla-bla\n@ät'
extended_edit.set_edit_text(BASE_STRING)
extended_edit.edit_pos = 6
extended_edit.keypress(10, 'ctrl w')
def test_extended_edit_input():
"""
Very basic test to make sure we don't break basic editing
We don't need to do more testing because that's done upstream. We basically
want to test that we properly forward unhandled keypresses.
"""
extended_edit = ExtendedEdit(mock.MagicMock())
extended_edit.keypress((10,), 'h')
extended_edit.keypress((10,), 'i')
assert extended_edit.get_edit_text() == 'hi'
def test_extended_edit_delete_next_char():
extended_edit = ExtendedEdit(None)
extended_edit.set_edit_text(BASE_STRING)
extended_edit.edit_pos = 9
extended_edit.keypress(10, 'ctrl d')
assert extended_edit.edit_pos == 9
assert extended_edit.get_edit_text() == 'The lazy ox bla bla\n@ät'
extended_edit.set_edit_text(BASE_STRING)
extended_edit.edit_pos = 0
extended_edit.keypress(10, 'ctrl d')
assert extended_edit.edit_pos == 0
assert extended_edit.get_edit_text() == 'he lazy fox bla bla\n@ät'
extended_edit.set_edit_text(BASE_STRING)
extended_edit.edit_pos = 24
extended_edit.keypress(10, 'ctrl d')
def _init_basic_fields(self):
self._summary = widgets.ExtendedEdit(
parent=self,
edit_text=self.todo.summary,
)
self._description = widgets.ExtendedEdit(
parent=self,
edit_text=self.todo.description,
multiline=True,
)
self._location = widgets.ExtendedEdit(
parent=self,
edit_text=self.todo.location,
)
self._due = widgets.ExtendedEdit(
parent=self,
edit_text=self.formatter.format_datetime(self.todo.due),
)
self._dtstart = widgets.ExtendedEdit(
parent=self,
edit_text=self.formatter.format_datetime(self.todo.start),
)
edit_text=self.todo.summary,
)
self._description = widgets.ExtendedEdit(
parent=self,
edit_text=self.todo.description,
multiline=True,
)
self._location = widgets.ExtendedEdit(
parent=self,
edit_text=self.todo.location,
)
self._due = widgets.ExtendedEdit(
parent=self,
edit_text=self.formatter.format_datetime(self.todo.due),
)
self._dtstart = widgets.ExtendedEdit(
parent=self,
edit_text=self.formatter.format_datetime(self.todo.start),
)
self._completed = urwid.CheckBox("", state=self.todo.is_completed)
self._priority = widgets.PrioritySelector(
parent=self,
priority=self.todo.priority,
formatter_function=self.formatter.format_priority,
)
def _init_basic_fields(self):
self._summary = widgets.ExtendedEdit(
parent=self,
edit_text=self.todo.summary,
)
self._description = widgets.ExtendedEdit(
parent=self,
edit_text=self.todo.description,
multiline=True,
)
self._location = widgets.ExtendedEdit(
parent=self,
edit_text=self.todo.location,
)
self._due = widgets.ExtendedEdit(
parent=self,
edit_text=self.formatter.format_datetime(self.todo.due),
)
self._dtstart = widgets.ExtendedEdit(
parent=self,
edit_text=self.formatter.format_datetime(self.todo.start),
)
self._completed = urwid.CheckBox("", state=self.todo.is_completed)
self._priority = widgets.PrioritySelector(
parent=self,
priority=self.todo.priority,
formatter_function=self.formatter.format_priority,
)
def _init_basic_fields(self):
self._summary = widgets.ExtendedEdit(
parent=self,
edit_text=self.todo.summary,
)
self._description = widgets.ExtendedEdit(
parent=self,
edit_text=self.todo.description,
multiline=True,
)
self._location = widgets.ExtendedEdit(
parent=self,
edit_text=self.todo.location,
)
self._due = widgets.ExtendedEdit(
parent=self,
edit_text=self.formatter.format_datetime(self.todo.due),
)