From f25ce181846128fc544b1b47b7eedad0bbde8c17 Mon Sep 17 00:00:00 2001 From: wudongze Date: Mon, 15 Jul 2024 14:16:23 +0800 Subject: [PATCH] Add two tests --- app/app/calc.py | 7 +++++++ app/app/tests.py | 15 +++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 app/app/calc.py create mode 100644 app/app/tests.py diff --git a/app/app/calc.py b/app/app/calc.py new file mode 100644 index 0000000..5af971e --- /dev/null +++ b/app/app/calc.py @@ -0,0 +1,7 @@ +# Calculator functions + +def add(x,y): + return x + y + +def subtract(x,y): + return x - y \ No newline at end of file diff --git a/app/app/tests.py b/app/app/tests.py new file mode 100644 index 0000000..d682a4e --- /dev/null +++ b/app/app/tests.py @@ -0,0 +1,15 @@ +# Sample test + +from django.test import SimpleTestCase + +from app import calc + +class CalcTests(SimpleTestCase): + # Test the calc module + def test_add_numbers(self): + res = calc.add(5, 6) + self.assertEqual(res, 11) + + def test_subtract_numbers(self): + res = calc.subtract(10, 5) + self.assertEqual(res, 5) \ No newline at end of file