    def test_file_filter(self, mock_list, mock_stat, mock_lstat, mock_dir, mock_link,
                         mock_real_path, mock_exists):
        """
        Check FileBrowser widget with a file_filter works as expected.
        """
        # First we need to mock out the file system calls to have a regressible test
        if sys.platform == "win32":
            self.skipTest("File names wrong for windows")

        mock_list.return_value = ["A Directory", "A File", "A Lnk", str(b"oo\xcc\x88o\xcc\x88O\xcc\x88.txt", 'utf-8'), "hello.bmp"]
        mock_result = MagicMock()
        mock_result.st_mtime = 0
        mock_result.st_size = 10000
        mock_stat.return_value = mock_result
        mock_lstat.return_value = mock_result
        mock_dir.side_effect = lambda x: x.endswith("Directory")
        mock_link.side_effect = lambda x: "Lnk" in x
        mock_real_path.return_value = "A Tgt"
        mock_exists.return_value = True

        # Now set up the Frame ready for testing
        screen = MagicMock(spec=Screen, colours=8, unicode_aware=False)
        scene = Scene([], -1)
        canvas = Canvas(screen, 10, 40, 0, 0)
        form = _TestFrame4(canvas, file_filter=r".*\.bmp$")
        scene.add_effect(form)
        form.reset()

        # Check we have a default value for our list.
        form.save()
        self.assertIsNone(form.selected)
        self.assertIsNone(form.highlighted)
        self.assertEqual(form.data, {"file_list": None})

        # Check that the Frame is rendered correctly.
        form.update(0)
        self.assert_canvas_equals(
            canvas,
            "/                     Size Last modified\n" +
            "|-+ A Directory         9K    %s\n" % self.epoch_date +
            "|-- hello.bmp           9K    %s\n" % self.epoch_date +
            "                                        \n" +
            "                                        \n" +
            "                                        \n" +
            "                                        \n" +
            "                                        \n" +
            "                                        \n" +
            "                                        \n")

        # Check that enter key handles correctly on files.
        self.process_keys(form, [Screen.KEY_DOWN, Screen.KEY_DOWN, Screen.ctrl("m")])
        self.assertEqual(form.highlighted, "/hello.bmp")
        self.assertEqual(form.selected, "/hello.bmp")
Check FileBrowser widget with a file_filter works as expected.
tests/test_widgets.py