'Regression test for https://github.com/astropy/astropy/issues/2750
Tests that the fake header (for the compressed image) can still be read
even if the real header contained a duplicate ZTENSION keyword (the
issue applies to any keyword specific to the compression convention,
however).'

def test_duplicate_compression_header_keywords(self):

    arr = np.arange(100, dtype=np.int32)
    hdu = fits.CompImageHDU(data=arr)
    header = hdu._header
    hdu._header.append(('ZTENSION', 'IMAGE'))
    hdu.writeto(self.temp('test.fits'))
    with fits.open(self.temp('test.fits')) as hdul:
        assert (header == hdul[1]._header)
        assert (hdul[1]._header.count('ZTENSION') == 2)
