From 7fd02fec9398b9c15c3e7e933019e019b23b3431 Mon Sep 17 00:00:00 2001 From: Harvir Sahota Date: Mon, 19 Feb 2024 12:36:17 -0800 Subject: [PATCH] Add harvir.py and harvir_test.py --- python/selfie-lib/selfie_lib/__init__.py | 1 + python/selfie-lib/selfie_lib/harvir.py | 4 ++++ python/selfie-lib/tests/harvir_test.py | 6 ++++++ 3 files changed, 11 insertions(+) create mode 100644 python/selfie-lib/selfie_lib/harvir.py create mode 100644 python/selfie-lib/tests/harvir_test.py diff --git a/python/selfie-lib/selfie_lib/__init__.py b/python/selfie-lib/selfie_lib/__init__.py index 3f126cd6..6f2000ed 100644 --- a/python/selfie-lib/selfie_lib/__init__.py +++ b/python/selfie-lib/selfie_lib/__init__.py @@ -1 +1,2 @@ from .ned import fizzbuzz as fizzbuzz +from .harvir import silly_addition as silly_addition diff --git a/python/selfie-lib/selfie_lib/harvir.py b/python/selfie-lib/selfie_lib/harvir.py new file mode 100644 index 00000000..8bcc9ed5 --- /dev/null +++ b/python/selfie-lib/selfie_lib/harvir.py @@ -0,0 +1,4 @@ +def silly_addition(a, b): + # Adds two numbers and then adds 42 to the result. + return a + b + 42 + diff --git a/python/selfie-lib/tests/harvir_test.py b/python/selfie-lib/tests/harvir_test.py new file mode 100644 index 00000000..8c7a5ce6 --- /dev/null +++ b/python/selfie-lib/tests/harvir_test.py @@ -0,0 +1,6 @@ +from selfie_lib import silly_addition + +def test_silly_addition(): + assert silly_addition(1, 2) == 45, "Should be 45" + assert silly_addition(-42, 0) == 0, "Should be 0" + assert silly_addition(10, 5) == 57, "Should be 57"