'Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/123
Tests assigning Python and Numpy boolean values to keyword values.'

def test_assign_boolean(self):

    fooimg = _pad('FOO                    =                                                                                T')
    barimg = _pad('BAR                    =                                                                                F')
    h = fits.Header()
    h['FOO'] = True
    h['BAR'] = False
    assert (h['FOO'] is True)
    assert (h['BAR'] is False)
    assert (str(h.cards['FOO']) == fooimg)
    assert (str(h.cards['BAR']) == barimg)
    h = fits.Header()
    h['FOO'] = np.bool_(True)
    h['BAR'] = np.bool_(False)
    assert (h['FOO'] is True)
    assert (h['BAR'] is False)
    assert (str(h.cards['FOO']) == fooimg)
    assert (str(h.cards['BAR']) == barimg)
    h = fits.Header()
    h.append(fits.Card.fromstring(fooimg))
    h.append(fits.Card.fromstring(barimg))
    assert (h['FOO'] is True)
    assert (h['BAR'] is False)
    assert (str(h.cards['FOO']) == fooimg)
    assert (str(h.cards['BAR']) == barimg)
