'Test extending the header with and without update=True.'

def test_header_extend_update(self):

    hdu = fits.PrimaryHDU()
    hdu2 = fits.ImageHDU()
    hdu.header['MYKEY'] = ('some    val', 'some    comment')
    hdu.header['HISTORY'] = 'history    1'
    hdu2.header['MYKEY'] = ('some    other    val', 'some    other    comment')
    hdu2.header['HISTORY'] = 'history    1'
    hdu2.header['HISTORY'] = 'history    2'
    hdu.header.extend(hdu2.header)
    assert (len(hdu.header) == 9)
    assert (('MYKEY', 0) in hdu.header)
    assert (('MYKEY', 1) in hdu.header)
    assert (hdu.header[('MYKEY', 1)] == 'some    other    val')
    assert (len(hdu.header['HISTORY']) == 3)
    assert (hdu.header[(-1)] == 'history    2')
    hdu = fits.PrimaryHDU()
    hdu.header['MYKEY'] = ('some    val', 'some    comment')
    hdu.header['HISTORY'] = 'history    1'
    hdu.header.extend(hdu2.header, update=True)
    assert (len(hdu.header) == 7)
    assert (('MYKEY', 0) in hdu.header)
    assert (('MYKEY', 1) not in hdu.header)
    assert (hdu.header['MYKEY'] == 'some    other    val')
    assert (len(hdu.header['HISTORY']) == 2)
    assert (hdu.header[(-1)] == 'history    2')
