diff --git a/calculator/ui/gui.py b/calculator/ui/gui.py index 221ca9b..79e1c1d 100644 --- a/calculator/ui/gui.py +++ b/calculator/ui/gui.py @@ -83,8 +83,10 @@ def on_button_press(self, button): self._calc.open_parenthesis() case "cos": self._calc.cos() + self._calc.open_parenthesis() case "sin": self._calc.sin() + self._calc.open_parenthesis() case _: self._calc.digit(button.text) self.display.text = self._calc.expression or "0" diff --git a/tests/test_gui.py b/tests/test_gui.py index 9192589..ae3d74a 100644 --- a/tests/test_gui.py +++ b/tests/test_gui.py @@ -78,7 +78,7 @@ def test_expression_with_cos(self): self.press_button(")") self.assert_display("cos(0)") self.press_button("=") - self.assert_display("1") + self.assert_display("1.0") def test_expression_with_sin(self): # sin(0) = 0 @@ -87,4 +87,4 @@ def test_expression_with_sin(self): self.press_button(")") self.assert_display("sin(0)") self.press_button("=") - self.assert_display("0") + self.assert_display("0.0") diff --git a/tests/test_model.py b/tests/test_model.py index 1acf17e..790984c 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -94,6 +94,7 @@ def test_cosine(self): # cos(0) = 1 self.assertEqual("", self.calculator.expression) self.calculator.cos() + self.calculator.open_parenthesis() self.assertEqual("cos(", self.calculator.expression) self.calculator.digit(0) self.calculator.close_parenthesis() @@ -104,6 +105,7 @@ def test_sine(self): # sin(0) = 0 self.assertEqual("", self.calculator.expression) self.calculator.sin() + self.calculator.open_parenthesis() self.assertEqual("sin(", self.calculator.expression) self.calculator.digit(0) self.calculator.close_parenthesis()