From c1564d9d04caeb226b08f3bbb47e91ac650daec9 Mon Sep 17 00:00:00 2001 From: "Hiroshi (Wes) Nishio" Date: Thu, 26 Feb 2026 12:30:13 -0800 Subject: [PATCH 1/8] Initial empty commit to create PR [skip ci] From d878b715dd7ad850c8be251069f86f1f6d8d0d2b Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Thu, 26 Feb 2026 20:31:27 +0000 Subject: [PATCH 2/8] Update test_calculator.py [skip ci] --- test_calculator.py | 100 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 test_calculator.py diff --git a/test_calculator.py b/test_calculator.py new file mode 100644 index 0000000..17d3f65 --- /dev/null +++ b/test_calculator.py @@ -0,0 +1,100 @@ +from unittest.mock import patch + +from calculator import add, divide, main, multiply, subtract + +import pytest + + +class TestAdd: + def test_positive_numbers(self): + assert add(2, 3) == 5 + + def test_negative_numbers(self): + assert add(-1, -2) == -3 + + def test_mixed_sign(self): + assert add(-1, 3) == 2 + + def test_zeros(self): + assert add(0, 0) == 0 + + def test_floats(self): + assert add(1.5, 2.5) == 4.0 + + +class TestSubtract: + def test_positive_numbers(self): + assert subtract(5, 3) == 2 + + def test_negative_result(self): + assert subtract(3, 5) == -2 + + def test_zeros(self): + assert subtract(0, 0) == 0 + + def test_floats(self): + assert subtract(5.5, 2.5) == 3.0 + + +class TestMultiply: + def test_positive_numbers(self): + assert multiply(3, 4) == 12 + + def test_by_zero(self): + assert multiply(5, 0) == 0 + + def test_negative_numbers(self): + assert multiply(-2, -3) == 6 + + def test_mixed_sign(self): + assert multiply(-2, 3) == -6 + + def test_floats(self): + assert multiply(2.5, 4) == 10.0 + + +class TestDivide: + def test_even_division(self): + assert divide(10, 2) == 5.0 + + def test_fractional_result(self): + assert divide(7, 2) == 3.5 + + def test_divide_by_zero_raises(self): + with pytest.raises(ValueError, match="Cannot divide by zero"): + divide(1, 0) + + def test_negative_numbers(self): + assert divide(-6, 3) == -2.0 + + def test_zero_numerator(self): + assert divide(0, 5) == 0.0 + + +class TestMain: + @patch("builtins.input", side_effect=["5", "+", "3"]) + @patch("builtins.print") + def test_addition_operation(self, mock_print, _mock_input): + main() + mock_print.assert_any_call("5.0 + 3.0 = 8.0") + + @patch("builtins.input", side_effect=["10", "-", "4"]) + @patch("builtins.print") + def test_subtraction_operation(self, mock_print, _mock_input): + main() + mock_print.assert_any_call("10.0 - 4.0 = 6.0") + + @patch("builtins.input", side_effect=["3", "*", "7"]) + @patch("builtins.print") + def test_multiplication_operation(self, mock_print, _mock_input): + main() + mock_print.assert_any_call("3.0 * 7.0 = 21.0") + + @patch("builtins.input", side_effect=["8", "/", "2"]) + @patch("builtins.print") + def test_division_operation(self, mock_print, _mock_input): + main() + mock_print.assert_any_call("8.0 / 2.0 = 4.0") + + @patch("builtins.input", side_effect=["5", "%", "3"]) + @patch("builtins.print") From 0c17abe84077fd2cf00d32c38d81b00821798fe3 Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Thu, 26 Feb 2026 20:31:59 +0000 Subject: [PATCH 3/8] Replace content of test_calculator.py [skip ci] --- test_calculator.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test_calculator.py b/test_calculator.py index 17d3f65..3ec32a3 100644 --- a/test_calculator.py +++ b/test_calculator.py @@ -98,3 +98,13 @@ def test_division_operation(self, mock_print, _mock_input): @patch("builtins.input", side_effect=["5", "%", "3"]) @patch("builtins.print") + def test_unknown_operation(self, mock_print, _mock_input): + main() + mock_print.assert_any_call("Unknown operation: %") + + @patch("builtins.input", side_effect=["5", "+", "3"]) + @patch("builtins.print") + def test_prints_header(self, mock_print, _mock_input): + main() + mock_print.assert_any_call("Simple Calculator") + mock_print.assert_any_call("Operations: +, -, *, /") From 1cc6c1149242a6e97f39e57255a0ecfbd362e48f Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Thu, 26 Feb 2026 20:33:08 +0000 Subject: [PATCH 4/8] Replace content of test_calculator.py [skip ci] --- test_calculator.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test_calculator.py b/test_calculator.py index 3ec32a3..02bd414 100644 --- a/test_calculator.py +++ b/test_calculator.py @@ -1,3 +1,4 @@ +# pylint: disable=redefined-outer-name, unused-argument from unittest.mock import patch from calculator import add, divide, main, multiply, subtract From 9b0e724f76ca98e6b616ab507548a6dce78ba270 Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Thu, 26 Feb 2026 20:33:10 +0000 Subject: [PATCH 5/8] Empty commit to trigger final tests From 52b1e36728192ecb39759d81f05a4f20c1244cf5 Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Thu, 26 Feb 2026 21:34:19 +0000 Subject: [PATCH 6/8] Update test_calculator.py [skip ci] --- test_calculator.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test_calculator.py b/test_calculator.py index 02bd414..7c71cc4 100644 --- a/test_calculator.py +++ b/test_calculator.py @@ -109,3 +109,6 @@ def test_prints_header(self, mock_print, _mock_input): main() mock_print.assert_any_call("Simple Calculator") mock_print.assert_any_call("Operations: +, -, *, /") + + def test_repeating_decimal(self): + assert divide(10, 3) == pytest.approx(3.3333333333333335) From 124ecba547a8b62d37026aa0260fe0dc0569438f Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Thu, 26 Feb 2026 21:35:07 +0000 Subject: [PATCH 7/8] Replace content of test_calculator.py [skip ci] --- test_calculator.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test_calculator.py b/test_calculator.py index 7c71cc4..0fd5de6 100644 --- a/test_calculator.py +++ b/test_calculator.py @@ -61,6 +61,9 @@ def test_even_division(self): def test_fractional_result(self): assert divide(7, 2) == 3.5 + def test_repeating_decimal(self): + assert divide(10, 3) == pytest.approx(10 / 3) + def test_divide_by_zero_raises(self): with pytest.raises(ValueError, match="Cannot divide by zero"): divide(1, 0) @@ -97,6 +100,12 @@ def test_division_operation(self, mock_print, _mock_input): main() mock_print.assert_any_call("8.0 / 2.0 = 4.0") + @patch("builtins.input", side_effect=["10", "/", "3"]) + @patch("builtins.print") + def test_division_repeating_decimal_operation(self, mock_print, _mock_input): + main() + mock_print.assert_any_call(f"10.0 / 3.0 = {10.0 / 3.0}") + @patch("builtins.input", side_effect=["5", "%", "3"]) @patch("builtins.print") def test_unknown_operation(self, mock_print, _mock_input): @@ -109,6 +118,3 @@ def test_prints_header(self, mock_print, _mock_input): main() mock_print.assert_any_call("Simple Calculator") mock_print.assert_any_call("Operations: +, -, *, /") - - def test_repeating_decimal(self): - assert divide(10, 3) == pytest.approx(3.3333333333333335) From 43bb57c09bb84bc1add5d2dd26779bec5d97b845 Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Thu, 26 Feb 2026 21:35:24 +0000 Subject: [PATCH 8/8] Empty commit to trigger final tests