'Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/146, and
for the solution that is optional stripping of whitespace from the end
of a header value.
By default extra whitespace is stripped off, but if
`fits.conf.strip_header_whitespace` = False it should not be
stripped.'

def test_header_strip_whitespace(self):

    h = fits.Header()
    h['FOO'] = 'Bar                        '
    assert (h['FOO'] == 'Bar')
    c = fits.Card.fromstring("QUX                    =    'Bar                                '")
    h.append(c)
    assert (h['QUX'] == 'Bar')
    assert (h.cards['FOO'].image.rstrip() == "FOO                    =    'Bar                        '")
    assert (h.cards['QUX'].image.rstrip() == "QUX                    =    'Bar                                '")
    with fits.conf.set_temp('strip_header_whitespace', False):
        assert (h['FOO'] == 'Bar                        ')
        assert (h['QUX'] == 'Bar                                ')
        assert (h.cards['FOO'].image.rstrip() == "FOO                    =    'Bar                        '")
        assert (h.cards['QUX'].image.rstrip() == "QUX                    =    'Bar                                '")
    assert (h['FOO'] == 'Bar')
    assert (h['QUX'] == 'Bar')
    assert (h.cards['FOO'].image.rstrip() == "FOO                    =    'Bar                        '")
    assert (h.cards['QUX'].image.rstrip() == "QUX                    =    'Bar                                '")
