'Tests fileinput.filelineno() when fileinput._state is not None.
Ensure that it invokes fileinput._state.filelineno() 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):

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