    def test_change_values(self):
        """
        Check changing Text values resets cursor position.
        """
        # Create a dummy screen.
        screen = MagicMock(spec=Screen, colours=8, unicode_aware=False)
        scene = Scene([], -1)
        canvas = Canvas(screen, 10, 40, 0, 0)

        # Create the form we want to test.
        form = Frame(canvas, canvas.height, canvas.width, has_border=False, can_scroll=False)
        layout = Layout([100], fill_frame=True)
        form.add_layout(layout)
        text = Text()
        layout.add_widget(text)
        form.fix()
        scene.add_effect(form)
        form.reset()

        # Check that input is put at the end of the new text
        text.value = "A test"
        self.process_keys(form, ["A"])
        form.save()
        self.assertEqual(text.value, "A testA")

        # Check that growing longer still puts it at the end.
        text.value = "A longer test"
        self.process_keys(form, ["A"])
        form.save()
        self.assertEqual(text.value, "A longer testA")
Check changing Text values resets cursor position.
tests/test_widgets.py