'file_move_safe() ignores a copystat() EPERM PermissionError. This
happens when the destination filesystem is CIFS, for example.'

def test_file_move_copystat_cifs(self):

    copystat_EACCES_error = PermissionError(errno.EACCES, 'msg')
    copystat_EPERM_error = PermissionError(errno.EPERM, 'msg')
    (handle_a, self.file_a) = tempfile.mkstemp()
    (handle_b, self.file_b) = tempfile.mkstemp()
    try:
        with mock.patch('django.core.files.move.os.rename', side_effect=OSError()):
            with mock.patch('django.core.files.move.copystat', side_effect=copystat_EACCES_error):
                with self.assertRaises(PermissionError):
                    file_move_safe(self.file_a, self.file_b, allow_overwrite=True)
            with mock.patch('django.core.files.move.copystat', side_effect=copystat_EPERM_error):
                self.assertIsNone(file_move_safe(self.file_a, self.file_b, allow_overwrite=True))
    finally:
        os.close(handle_a)
        os.close(handle_b)
