'Test the various different ways of specifying an extension header in
the convenience functions.'

def test_getext(self):

    (hl, ext) = _getext(self.data('test0.fits'), 'readonly', 1)
    assert (ext == 1)
    pytest.raises(ValueError, _getext, self.data('test0.fits'), 'readonly', 1, 2)
    pytest.raises(ValueError, _getext, self.data('test0.fits'), 'readonly', (1, 2))
    pytest.raises(ValueError, _getext, self.data('test0.fits'), 'readonly', 'sci', 'sci')
    pytest.raises(TypeError, _getext, self.data('test0.fits'), 'readonly', 1, 2, 3)
    (hl, ext) = _getext(self.data('test0.fits'), 'readonly', ext=1)
    assert (ext == 1)
    (hl, ext) = _getext(self.data('test0.fits'), 'readonly', ext=('sci', 2))
    assert (ext == ('sci', 2))
    pytest.raises(TypeError, _getext, self.data('test0.fits'), 'readonly', 1, ext=('sci', 2), extver=3)
    pytest.raises(TypeError, _getext, self.data('test0.fits'), 'readonly', ext=('sci', 2), extver=3)
    (hl, ext) = _getext(self.data('test0.fits'), 'readonly', 'sci')
    assert (ext == ('sci', 1))
    (hl, ext) = _getext(self.data('test0.fits'), 'readonly', 'sci', 1)
    assert (ext == ('sci', 1))
    (hl, ext) = _getext(self.data('test0.fits'), 'readonly', ('sci', 1))
    assert (ext == ('sci', 1))
    (hl, ext) = _getext(self.data('test0.fits'), 'readonly', 'sci', extver=1, do_not_scale_image_data=True)
    assert (ext == ('sci', 1))
    pytest.raises(TypeError, _getext, self.data('test0.fits'), 'readonly', 'sci', ext=1)
    pytest.raises(TypeError, _getext, self.data('test0.fits'), 'readonly', 'sci', 1, extver=2)
    (hl, ext) = _getext(self.data('test0.fits'), 'readonly', extname='sci')
    assert (ext == ('sci', 1))
    (hl, ext) = _getext(self.data('test0.fits'), 'readonly', extname='sci', extver=1)
    assert (ext == ('sci', 1))
    pytest.raises(TypeError, _getext, self.data('test0.fits'), 'readonly', extver=1)
