'Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/105
Replacing the original header to an image HDU and saving should update
the NAXISn keywords appropriately and save the image data correctly.'

def test_image_update_header(self):

    self.copy_file('test0.fits')
    with fits.open(self.temp('test0.fits'), mode='update') as hdul:
        orig_data = hdul[1].data.copy()
        hdr_copy = hdul[1].header.copy()
        del hdr_copy['NAXIS*']
        hdul[1].header = hdr_copy
    with fits.open(self.temp('test0.fits')) as hdul:
        assert (orig_data == hdul[1].data).all()
