'Test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/109
Allow opening files with headers containing invalid keywords.'

def test_invalid_keyword_cards(self):

    c1 = fits.Card.fromstring('CLFIND2D:    contour    =    0.30')
    c2 = fits.Card.fromstring('Just    some    random    text.')
    c3 = fits.Card.fromstring(('A' * 80))
    hdu = fits.PrimaryHDU()
    with catch_warnings() as w:
        hdu.header.append(c1)
        hdu.header.append(c2)
        hdu.header.append(c3)
    assert (len(w) == 3)
    hdu.writeto(self.temp('test.fits'))
    with catch_warnings() as w:
        with fits.open(self.temp('test.fits')) as hdul:
            assert (len(w) == 3)
            header = hdul[0].header
            assert ('CLFIND2D' in header)
            assert ('Just    som' in header)
            assert ('AAAAAAAA' in header)
            assert (header['CLFIND2D'] == ':    contour    =    0.30')
            assert (header['Just    som'] == 'e    random    text.')
            assert (header['AAAAAAAA'] == ('A' * 72))
            pytest.raises(ValueError, header.set, 'CLFIND2D', 'foo')
            pytest.raises(ValueError, header.set, 'Just    som', 'foo')
            pytest.raises(ValueError, header.set, 'AAAAAAAA', 'foo')
