'Regression test for
https://github.com/spacetelescope/PyFITS/issues/25
Replacing the mmap\'d data of one file with mmap\'d data from a
different file should work.'

def test_replace_mmap_data(self):

    arr_a = np.arange(10)
    arr_b = (arr_a * 2)
    def test(mmap_a, mmap_b):
        hdu_a = fits.PrimaryHDU(data=arr_a)
        hdu_a.writeto(self.temp('test_a.fits'), overwrite=True)
        hdu_b = fits.PrimaryHDU(data=arr_b)
        hdu_b.writeto(self.temp('test_b.fits'), overwrite=True)
        hdul_a = fits.open(self.temp('test_a.fits'), mode='update', memmap=mmap_a)
        hdul_b = fits.open(self.temp('test_b.fits'), memmap=mmap_b)
        hdul_a[0].data = hdul_b[0].data
        hdul_a.close()
        hdul_b.close()
        hdul_a = fits.open(self.temp('test_a.fits'))
        assert np.all((hdul_a[0].data == arr_b))
    with ignore_warnings():
        test(True, True)
        test(False, True)
        test(True, False)
