'Regression test for https://github.com/astropy/astropy/issues/968
Temporarily patches mmap.mmap to exhibit platform-specific bad
behavior.'

def test_mmap_unwriteable(self):

    class MockMmap(mmap.mmap, ):
        def flush(self):
            raise mmap.error('flush    is    broken    on    this    platform')
    old_mmap = mmap.mmap
    mmap.mmap = MockMmap
    _File.__dict__['_mmap_available']._cache.clear()
    try:
        self.copy_file('test0.fits')
        with catch_warnings() as w:
            with fits.open(self.temp('test0.fits'), mode='update', memmap=True) as h:
                h[1].data[(0, 0)] = 999
            assert (len(w) == 1)
            assert ('mmap.flush    is    unavailable' in str(w[0].message))
        with fits.open(self.temp('test0.fits')) as h:
            assert (h[1].data[(0, 0)] == 999)
    finally:
        mmap.mmap = old_mmap
        _File.__dict__['_mmap_available']._cache.clear()
