unit testing a method that asks two user inputs() in console - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: unit testing a method that asks two user inputs() in console (/thread-17252.html) |
unit testing a method that asks two user inputs() in console - gebel - Apr-03-2019 Hi, I am really struggling to unittest the following simple method: def add(): a = int(input('Enter first number ')) b= int(input('Enter second number ')) return a + bI tried the following but it failed: 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) |