Apr-03-2019, 07:59 PM
Hi,
I am really struggling to unittest the following simple method:
I tried the following but it failed:
I am really struggling to unittest the following simple method:
1 2 3 4 |
def add(): a = int ( input ( 'Enter first number ' )) b = int ( input ( 'Enter second number ' )) return a + b |
1 2 3 4 5 6 7 8 9 |
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 ) |