diff --git a/.github/workflows/pytest_ci.yaml b/.github/workflows/pytest_ci.yaml new file mode 100644 index 0000000..a13d4f2 --- /dev/null +++ b/.github/workflows/pytest_ci.yaml @@ -0,0 +1,26 @@ +name: Python CI + +on: push + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.11 + architecture: x64 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Run tests with pytest + run: | + python -m pytest diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e079f8a --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +pytest diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_add.py b/tests/test_add.py new file mode 100644 index 0000000..f9406a1 --- /dev/null +++ b/tests/test_add.py @@ -0,0 +1,14 @@ +import pytest +from typing import Union + +from main import add + + +@pytest.mark.parametrize( + "a, b, expected", + [(1, 2, 3), (1.0, 2.0, 3.0), (1, 2.0, 3.0), (1.0, 2, 3.0), (0, 0, 0), (-1, -1, -2)], +) +def test_add(a: Union[int, float], b: Union[int, float], expected: Union[int, float]): + result = add(a, b) + + assert result == expected