'Regression test for
https://github.com/astropy/astropy/issues/3883#issuecomment-115122647
Ensure that when scaled data is automatically rescaled on
opening/writing a file that the checksum and datasum are computed for
the rescaled array.'

def test_scaled_data_auto_rescale(self):

    with fits.open(self.data('scale.fits')) as hdul:
        hdul.writeto(self.temp('rescaled.fits'))
    with fits.open(self.temp('rescaled.fits')) as hdul:
        hdul.writeto(self.temp('rescaled2.fits'), overwrite=True, checksum=True)
    with fits.open(self.data('scale.fits')) as hdul:
        hdul.writeto(self.temp('rescaled3.fits'), checksum=True)
    with fits.open(self.data('scale.fits'), do_not_scale_image_data=True) as hdul:
        hdul.writeto(self.temp('scaled.fits'), checksum=True)
    with fits.open(self.temp('rescaled2.fits')) as hdul1:
        with fits.open(self.temp('rescaled3.fits')) as hdul2:
            with fits.open(self.temp('scaled.fits')) as hdul3:
                hdr1 = hdul1[0].header
                hdr2 = hdul2[0].header
                hdr3 = hdul3[0].header
                assert (hdr1['DATASUM'] == hdr2['DATASUM'])
                assert (hdr1['CHECKSUM'] == hdr2['CHECKSUM'])
                assert (hdr1['DATASUM'] != hdr3['DATASUM'])
                assert (hdr1['CHECKSUM'] != hdr3['CHECKSUM'])
