I am trying to create a test case for mocking multiple user inputs for the function below:
class Input_Data(Unit_Conversion):
def __init__(self):
self.input_val = round(float(input("Please enter the input value: ").strip()), 2)
self.input_unit = input("Select Input Unit of Measure: Kelvin, Celsius, Fahrenheit, Rankine: " ).strip().capitalize()
self.res_val = input("Please enter the student's response value: ").strip()
self.target_unit = input("Select Target Unit of Measure: Kelvin, Celsius, Fahrenheit, Rankine: " ).strip().capitalize()
super().__init__(self.input_val, self.input_unit, self.res_val, self.target_unit)
The test case I have below is passing however it still prompts the user to input the same values to pass.
class TestConversion(unittest.TestCase):
@patch('builtins.input', side_effect=['38.81', 'C', '101.3', 'F'])
def test_inputs(self, input):
Input_Data()
assert sys.stdout.getline().strip() == "38.81 C is Correct!"
However, I want it to be automated so it mocks the user input.
This post related to my question does not talk about multiple user inputs but a single input and is not much help to me.