'Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/149
Basically ensures that all public Header methods are case-insensitive
w.r.t. keywords.
Provides a reasonably comprehensive test of several methods at once.'

def test_header_method_keyword_normalization(self):

    h = fits.Header([('abC', 1), ('Def', 2), ('GeH', 3)])
    assert (list(h) == ['ABC', 'DEF', 'GEH'])
    assert ('abc' in h)
    assert ('dEf' in h)
    assert (h['geh'] == 3)
    assert (len(h['g*']) == 1)
    h['aBc'] = 2
    assert (h['abc'] == 2)
    assert (len(h) == 3)
    del h['gEh']
    assert (list(h) == ['ABC', 'DEF'])
    assert (len(h) == 2)
    assert (h.get('def') == 2)
    h.set('Abc', 3)
    assert (h['ABC'] == 3)
    h.set('gEh', 3, before='Abc')
    assert (list(h) == ['GEH', 'ABC', 'DEF'])
    assert (h.pop('abC') == 3)
    assert (len(h) == 2)
    assert (h.setdefault('def', 3) == 2)
    assert (len(h) == 2)
    assert (h.setdefault('aBc', 1) == 1)
    assert (len(h) == 3)
    assert (list(h) == ['GEH', 'DEF', 'ABC'])
    h.update({'GeH': 1, 'iJk': 4})
    assert (len(h) == 4)
    assert (list(h) == ['GEH', 'DEF', 'ABC', 'IJK'])
    assert (h['GEH'] == 1)
    assert (h.count('ijk') == 1)
    assert (h.index('ijk') == 3)
    h.remove('Def')
    assert (len(h) == 3)
    assert (list(h) == ['GEH', 'ABC', 'IJK'])
