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

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