From 1bf5b8c6e1c601c92755bbbc3453050a933841a8 Mon Sep 17 00:00:00 2001 From: fdai7763 Date: Tue, 23 Jan 2024 21:15:18 +0100 Subject: [PATCH] added test for returning simplified math-function from read-function when entering an allowed math-function as well as corresponding functionality --- src/main/py/read_math_function.py | 7 ++++++- src/test/py/test_read_math_function.py | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/py/read_math_function.py b/src/main/py/read_math_function.py index 815b256..7507e13 100644 --- a/src/main/py/read_math_function.py +++ b/src/main/py/read_math_function.py @@ -7,7 +7,12 @@ def read_math_function(): print("k - verkettete Funktionen (Demnächst verfügbar)") print("x - Ich möchte nichts mehr einlesen lassen") type = input("Zur Zeit können nur Konstanten eingelesen werden. Bitte geben Sie den Typ ihrer Funktion ein:" ) - if type == "x": + if type != "x": + function = input("Ihre Funktion: ") + simplified = simplify_constant(type, function) + return simplified + + else: return False diff --git a/src/test/py/test_read_math_function.py b/src/test/py/test_read_math_function.py index 0ca4581..5b37c78 100644 --- a/src/test/py/test_read_math_function.py +++ b/src/test/py/test_read_math_function.py @@ -28,6 +28,9 @@ class read_function(unittest.TestCase): def test_read_math_function_false_if_enter_x(self, mock_input): result = read_math_function() self.assertFalse(result) + @patch('builtins.input', side_effect=["c", "5"]) + def test_read_math_function_return5_if_enter_c_5(self, mock_input): + self.assertEqual(read_math_function(), 5) if __name__ == '__main__': unittest.main()