'Regression test for
https://github.com/spacetelescope/PyFITS/issues/33
Check that a new GzipFile opened in append mode can be used to write
out a new FITS file.'

def test_writeto_append_mode_gzip(self):

    fileobj = gzip.GzipFile(self.temp('test.fits.gz'), 'ab+')
    h = fits.PrimaryHDU()
    try:
        h.writeto(fileobj)
    finally:
        fileobj.close()
    with fits.open(self.temp('test.fits.gz')) as hdul:
        assert (hdul[0].header == h.header)
