'Test that it gives a readable error when trying to write an hdulist
to a full disk.'

def test_writeto_full_disk(self, monkeypatch):

    def _writeto(self, array):
        raise OSError('Fake    error    raised    when    writing    file.')
    def get_free_space_in_dir(path):
        return 0
    with pytest.raises(OSError) as exc:
        monkeypatch.setattr(fits.hdu.base._BaseHDU, '_writeto', _writeto)
        monkeypatch.setattr(data, 'get_free_space_in_dir', get_free_space_in_dir)
        n = np.arange(0, 1000, dtype='int64')
        hdu = fits.PrimaryHDU(n)
        hdulist = fits.HDUList(hdu)
        filename = self.temp('test.fits')
        with open(filename, mode='wb+') as fileobj:
            hdulist.writeto(fileobj)
    assert ('Not    enough    space    on    disk:    requested    8000,    available    0.    Fake    error    raised    when    writing    file.' == exc.value.args[0])
