Browse Source

added test for returning simplified math-function from read-function when entering an allowed math-function as well as corresponding functionality

remotes/origin/feature/feature-read-math-functions
fdai7763 11 months ago
parent
commit
1bf5b8c6e1
  1. 7
      src/main/py/read_math_function.py
  2. 3
      src/test/py/test_read_math_function.py

7
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

3
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()
Loading…
Cancel
Save