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 -

asp.net mvc - How to attach sql database to a javascript graph -

c# - How to know the number of Threads created and limit the Tasks accordingly -