title: Testing getpass module: 'password input may be echoed'
body: <p>I'm looking for any insight into why the below error is raised. I'm wondering if the issue is with pytest?</p>
  
  <p>I'm otherwise using getpass with no issues in my application. However, I'm new to the testing world.</p>
  
  <p><strong>common.py</strong>:</p>
  
  <pre><code>def username_password():
      """Get login credentials"""
      # show current windows user
      print("\nThe current windows user is {}\n".format(getuser()))
  
      username = getpass("Username: ")
      password = getpass("Password: ")
      return username, password
  </code></pre>
  
  <p><strong>test_common.py</strong>:</p>
  
  <pre><code>from unittest.mock import patch
  from common import username_password
  
  @patch("getpass.getpass")
  @patch("getpass.getuser")
  def test_username_password(getuser, getpass):
      getuser.return_value = "Me"
      getpass.return_value = "xxx"
      assert username_password() == ("Me", "xxx")
  </code></pre>
  
  <p><strong>Command line</strong>:</p>
  
  <pre><code>py.test test_common.py --cov  --cov-report term-missing
  ============================= test session starts =============================
  platform win32 -- Python 3.5.2, pytest-2.9.2, py-1.4.31, pluggy-0.3.1
  rootdir: C:\Users\JB\Desktop\Coding\Bot\Bot_tests, inifile:
  plugins: cov-2.5.1
  collected 17 items
  
  test_common.py ....F..x.........
  
  ================================== FAILURES ===================================
  ___________________________ test_username_password ____________________________
  
  getuser = &lt;MagicMock name='getuser' id='1759491735280'&gt;
  getpass = &lt;MagicMock name='getpass' id='1759491732424'&gt;
  
      @patch("getpass.getpass")
      @patch("getpass.getuser")
      def test_username_password(getuser, getpass):
          getuser.return_value = "Me"
          getpass.return_value = "xxx"
  &gt;       u, p = username_password()
  
  test_common.py:65:
  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  ..\Bot\common.py:29: in username_password
      username = getpass("Username: ")
  ..\..\environments\ipython_env\Anaconda3\lib\getpass.py:101: in win_getpass
      return fallback_getpass(prompt, stream)
  ..\..\environments\ipython_env\Anaconda3\lib\getpass.py:127: in fallback_getpass
      return _raw_input(prompt, stream)
  ..\..\environments\ipython_env\Anaconda3\lib\getpass.py:147: in _raw_input
      line = input.readline()
  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  
  self = &lt;_pytest.capture.DontReadFromInput object at 0x00000199A8BD37F0&gt;
  args = ()
  
      def read(self, *args):
  &gt;       raise IOError("reading from stdin while output is captured")
  E       OSError: reading from stdin while output is captured
  
  ..\..\environments\ipython_env\Anaconda3\lib\site-packages\_pytest\capture.py:433: OSError
  ---------------------------- Captured stdout call -----------------------------
  
  The current windows user is JB
  
  ---------------------------- Captured stderr call -----------------------------
  C:\Users\JB\Desktop\Coding\environments\ipython_env\Anaconda3\lib\getpass.py:101: GetPassWarning: Can not control echo on the terminal.
    return fallback_getpass(prompt, stream)
  Warning: Password input may be echoed.
  Username:
  =============== 1 failed, 15 passed, 1 xfailed in 0.50 seconds ================
  </code></pre>
  
  <p>Any input appreciated. </p>
  
  <p>Now babbling in the hope that the system will grant me the ability to post and stop asking for more details. I have nothing more to add.</p>