'Test that invalid use of the BLANK keyword leads to an appropriate
warning, and that the BLANK keyword is ignored when returning the
HDU data.
Regression test for https://github.com/astropy/astropy/issues/3865'

def test_invalid_blanks(self):

    arr = np.arange(5, dtype=np.float64)
    hdu = fits.PrimaryHDU(data=arr)
    hdu.header['BLANK'] = 2
    with catch_warnings() as w:
        hdu.writeto(self.temp('test_new.fits'))
        assert (len(w) == 1)
        assert ("Invalid    'BLANK'    keyword    in    header" in str(w[0].message))
    with catch_warnings() as w:
        with fits.open(self.temp('test_new.fits')) as h:
            assert (len(w) == 1)
            assert ("Invalid    'BLANK'    keyword    in    header" in str(w[0].message))
            assert np.all((arr == h[0].data))
