title: Pytest doesn't set attribute to mock object
body: <p>Here is a test case code:</p>
  
  <pre><code>def test_interactive_session_set_language(monkeypatch):
      """Test user possibility to select language."""
  
      events = [':ru-en', EOFError]
  
      mock_input = mock.Mock(side_effect=events)
  
      mock_set_language = mock.Mock()
  
      monkeypatch.setattr('builtins.input', mock_input)
      monkeypatch.setattr('pylingvo.interactive.pylingvo.client.set_language',
                          mock_set_language)
  
      with pytest.raises(SystemExit):
  
          pylingvo.interactive.start_session()
  
      assert mock_set_language.call_count == 1
  </code></pre>
  
  <p>Here is a module code:</p>
  
  <pre><code>import pylingvo.client
  import sys
  import re
  
  
  def start_session():
      """Start interactive session."""
  
      while True:
  
          try:
  
              line = input('&gt; ')
  
          except (EOFError, KeyboardInterrupt):
  
              sys.exit()
  
          else:
  
              command = dispatch(line)
  
  
  COMMAND_MATCH_PATTERNS = [
      ('^:[a-z]{2}-[a-z]{2}$', pylingvo.client.set_language),
      ('^.*$', Exception),
  ]
  
  
  COMMAND_MATCH_TABLE = [(re.compile(regex), command)
                         for regex, command in COMMAND_MATCH_PATTERNS]
  
  
  def dispatch(command_name):
      """Convert interactive input to callable object."""
  
      for pattern, command in COMMAND_MATCH_TABLE:
  
          if pattern.match(command_name):
  
              return command
  </code></pre>
  
  <p>This test case failed with this message:</p>
  
  <pre><code>E       assert 0 == 1
  E        +  where 0 = &lt;Mock id='139806765631632'&gt;.call_count
  </code></pre>
  
  <p>As we can see mock object doesn't called due test run.  So my question
  is how to set mock attribute properly then this test case can pass?</p>