'Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/119
(Don\'t update scaled image data if the data is not read)
This ensures that merely opening and closing a file containing scaled
image data does not cause any change to the data (or the header).
Changes should only occur if the data is accessed.'

def test_open_scaled_in_update_mode(self):

    self.copy_file('scale.fits')
    mtime = os.stat(self.temp('scale.fits')).st_mtime
    time.sleep(1)
    fits.open(self.temp('scale.fits'), mode='update').close()
    assert (mtime == os.stat(self.temp('scale.fits')).st_mtime)
    time.sleep(1)
    hdul = fits.open(self.temp('scale.fits'), 'update')
    orig_data = hdul[0].data
    hdul.close()
    assert (mtime != os.stat(self.temp('scale.fits')).st_mtime)
    hdul = fits.open(self.temp('scale.fits'), mode='update')
    assert (hdul[0].data.dtype == np.dtype('>f4'))
    assert (hdul[0].header['BITPIX'] == (-32))
    assert ('BZERO' not in hdul[0].header)
    assert ('BSCALE' not in hdul[0].header)
    assert (orig_data == hdul[0].data).all()
    hdul[0].data.shape = (42, 10)
    hdul.close()
    hdul = fits.open(self.temp('scale.fits'))
    assert (hdul[0].shape == (42, 10))
    assert (hdul[0].data.dtype == np.dtype('>f4'))
    assert (hdul[0].header['BITPIX'] == (-32))
    assert ('BZERO' not in hdul[0].header)
    assert ('BSCALE' not in hdul[0].header)
