From fea94ab33acc8768c744878927a084d516644631 Mon Sep 17 00:00:00 2001 From: paACode Date: Wed, 4 Mar 2026 14:15:35 +0100 Subject: [PATCH 1/3] Adjusted Docstring again --- code/calculator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/calculator.py b/code/calculator.py index 0fa0a54..0b415d0 100644 --- a/code/calculator.py +++ b/code/calculator.py @@ -1,4 +1,4 @@ -"""A simple calculator module that provides basic arithmetic operations.""" +"""A simple calculator module that provides basic operations.""" def add(a: float, b: float) -> int: """Add two numbers and return the result.""" return a + b From 62ba98d4ce30dc1b56a19153dde22b72d9bc4a2c Mon Sep 17 00:00:00 2001 From: paACode Date: Wed, 4 Mar 2026 14:25:31 +0100 Subject: [PATCH 2/3] Should be fixed --- README.md | 4 ++-- code/calculator.py | 2 +- tests/__init__.py | 0 tests/test_calculator.py | 6 +++++- 4 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 tests/__init__.py diff --git a/README.md b/README.md index a258773..4e59365 100644 --- a/README.md +++ b/README.md @@ -20,5 +20,5 @@ autopep8 --in-place code/myfile.py mypy . - pylint $(git ls-files '*.py') --fail-under=8.0 - pytest --cov=. --cov-fail-under=80 \ No newline at end of file + pylint $(git ls-files '*.py') --fail-under=8.0 + pytest --cov=. --cov-fail-under=80 \ No newline at end of file diff --git a/code/calculator.py b/code/calculator.py index 0b415d0..77e1607 100644 --- a/code/calculator.py +++ b/code/calculator.py @@ -1,4 +1,4 @@ """A simple calculator module that provides basic operations.""" -def add(a: float, b: float) -> int: +def add(a: float, b: float) -> float: """Add two numbers and return the result.""" return a + b diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_calculator.py b/tests/test_calculator.py index 81f80c7..6d17e74 100644 --- a/tests/test_calculator.py +++ b/tests/test_calculator.py @@ -1,19 +1,23 @@ -import pytest +"""Unit tests for the calculator module.""" from code.calculator import add def test_add_positive_numbers() -> None: + """Test adding two positive numbers.""" assert add(2, 3) == 5 def test_add_negative_numbers() -> None: + """Test adding two negative numbers.""" assert add(-2, -3) == -5 def test_add_mixed_numbers() -> None: + """Test adding a positive and a negative number.""" assert add(-2, 5) == 3 def test_add_floats() -> None: + """Test adding two floating-point numbers.""" assert add(2.5, 3.5) == 6.0 From 607ddf08f7bbaf24fa28d103004de500317fb3ed Mon Sep 17 00:00:00 2001 From: paACode Date: Wed, 4 Mar 2026 14:30:26 +0100 Subject: [PATCH 3/3] src instead of code folder, solves issue accessing pytest and pylint --- {code => src}/__init__.py | 0 {code => src}/calculator.py | 0 tests/test_calculator.py | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) rename {code => src}/__init__.py (100%) rename {code => src}/calculator.py (100%) diff --git a/code/__init__.py b/src/__init__.py similarity index 100% rename from code/__init__.py rename to src/__init__.py diff --git a/code/calculator.py b/src/calculator.py similarity index 100% rename from code/calculator.py rename to src/calculator.py diff --git a/tests/test_calculator.py b/tests/test_calculator.py index 6d17e74..dabf164 100644 --- a/tests/test_calculator.py +++ b/tests/test_calculator.py @@ -1,6 +1,6 @@ """Unit tests for the calculator module.""" -from code.calculator import add +from src.calculator import add def test_add_positive_numbers() -> None: