    def test_frame_focus_widget_property(self):
        """
        Check the frame exposes the focussed widget
        """
        screen = MagicMock(spec=Screen, colours=8, unicode_aware=False)
        canvas = Canvas(screen, 10, 40, 0, 0)
        scene = Scene([], -1)
        form = _TestFrame(canvas)
        scene.add_effect(form)
        form.reset()

        # If the Frame loses the focus it must not return a focussed widget.
        form._has_focus = False
        self.assertIsNone(form.focussed_widget)

        # If the Frame focus is undefined, it must not return a focussed widget.
        form._has_focus = True
        form._focus = 9999
        self.assertIsNone(form.focussed_widget)

        # Refixing frame resets focus when needed.
        form._focus = 0
        old_focus = form.focussed_widget
        self.assertIsNotNone(old_focus)
        form._layouts[0].clear_widgets()
        form.fix()
        self.assertNotEqual(form.focussed_widget, old_focus)

        # Moving focus to undefined widget has no effect.
        old_focus = form.focussed_widget
        form.switch_focus(None, 0, 0)
        self.assertEqual(form.focussed_widget, old_focus)

        # Blurring removes focus.
        form.blur()
        self.assertIsNone(form.focussed_widget)
Check the frame exposes the focussed widget
tests/test_widgets.py