'Tests the `--table` feature of the `fitsheader` script.'

def test_fitsheader_table_feature(self):

    from ....io import fits
    from ....io.fits.scripts import fitsheader
    test_filename = self.data('zerowidth.fits')
    fitsobj = fits.open(test_filename)
    formatter = fitsheader.TableHeaderFormatter(test_filename)
    mytable = formatter.parse([0])
    assert (len(mytable) == len(fitsobj[0].header))
    mytable = formatter.parse(extensions=['AIPS    FQ', 2, '4'])
    assert (len(mytable) == ((len(fitsobj['AIPS    FQ'].header) + len(fitsobj[2].header)) + len(fitsobj[4].header)))
    mytable = formatter.parse(extensions=['AIPS    FQ'])
    assert np.all((mytable['filename'] == test_filename))
    assert np.all((mytable['hdu'] == 'AIPS    FQ'))
    assert (mytable['value'][(mytable['keyword'] == 'EXTNAME')] == 'AIPS    FQ')
    mytable = formatter.parse(extensions=['AIPS    FQ'], keywords=['EXTNAME'])
    assert (len(mytable) == 1)
    assert (mytable['hdu'][0] == 'AIPS    FQ')
    assert (mytable['keyword'][0] == 'EXTNAME')
    assert (mytable['value'][0] == 'AIPS    FQ')
    mytable = formatter.parse(extensions=['DOES_NOT_EXIST'])
    assert (mytable is None)
    mytable = formatter.parse(extensions=['AIPS    FQ'], keywords=['DOES_NOT_EXIST'])
    assert (mytable is None)
