testing a function which takes input from user (python) -


The function below takes the password from the user I need this test unit test / (socks).

  def create_auth (): username = '{user}' Format (user = getpass.getuser ()) pwd = getpass  

I am new to python, any sign will be useful

thanks

Do:

  Class TestCreateAuth (Unittest.TestCase): @ mock.patch ('getpass.getpass') @Mock. Patch ('getpass.getuser') def test_create_auth (auto, recipient, getpw): getuser.return_value = 'user' getpw.return_value = 'pass' self.assertEqual (create_auth (), 'user: pass')  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -