Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
pylint $(git ls-files '*.py') --fail-under=8.0
pytest --cov=. --cov-fail-under=80
4 changes: 0 additions & 4 deletions code/calculator.py

This file was deleted.

File renamed without changes.
4 changes: 4 additions & 0 deletions src/calculator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""A simple calculator module that provides basic operations."""
def add(a: float, b: float) -> float:
"""Add two numbers and return the result."""
return a + b
Empty file added tests/__init__.py
Empty file.
8 changes: 6 additions & 2 deletions tests/test_calculator.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import pytest
"""Unit tests for the calculator module."""

from code.calculator import add
from src.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