'Tests fileinput.isfirstline() when fileinput._state is not None.
Ensure that it invokes fileinput._state.isfirstline() exactly once,
returns whatever it returns, and does not modify fileinput._state
to point to a different object.'

def test_state_is_not_None(self):

    isfirstline_retval = object()
    instance = MockFileInput()
    instance.return_values['isfirstline'] = isfirstline_retval
    fileinput._state = instance
    retval = fileinput.isfirstline()
    self.assertExactlyOneInvocation(instance, 'isfirstline')
    self.assertIs(retval, isfirstline_retval)
    self.assertIs(fileinput._state, instance)
