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

mysql - How to enter php data into a html multiple select box -

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

c++ - Cassandra datastax cpp driver - avoiding unnecessary copies -