My console app is simply adding two numbers:
def add():
a=int(input('Enter first number '))
b= int(input('Enter second number '))
return a + b
how do I unit test the above method? I tried the following but I can't seem to pass two values to it:
import unittest
from unittest.mock import patch
@patch('builtins.input', return_value='2')
@patch('builtins.input', return_value='3')
def test_add(self, a, b ):
self.assertEqual(result, 5)
While I don't get the prompts asking for numbers during testing, the tests are failing because both a and b are 2.