From 28d581c6c09a6ff1bca2f940d9c64936fe6bd9f2 Mon Sep 17 00:00:00 2001 From: Lars Buntemeyer Date: Mon, 21 Oct 2024 13:24:51 +0200 Subject: [PATCH 1/3] added test structure --- pyproject.toml | 4 ++++ science_project/__init__.py | 2 ++ science_project/main.py | 2 ++ science_project/tests/__init__.py | 0 science_project/tests/test_project.py | 6 ++++++ 5 files changed, 14 insertions(+) create mode 100644 science_project/main.py create mode 100644 science_project/tests/__init__.py create mode 100644 science_project/tests/test_project.py diff --git a/pyproject.toml b/pyproject.toml index 66ce77b..0f781f5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,3 +12,7 @@ packages = ["science_project"] [tool.setuptools.dynamic] dependencies = {file = ["requirements.txt"]} + +[tool.pytest] +python_files = "test_*.py" +testpaths = ["science_project/tests"] diff --git a/science_project/__init__.py b/science_project/__init__.py index e69de29..543f1ad 100644 --- a/science_project/__init__.py +++ b/science_project/__init__.py @@ -0,0 +1,2 @@ + +from .main import add_one diff --git a/science_project/main.py b/science_project/main.py new file mode 100644 index 0000000..c929f88 --- /dev/null +++ b/science_project/main.py @@ -0,0 +1,2 @@ +def add_one(number): + return number + 1 diff --git a/science_project/tests/__init__.py b/science_project/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/science_project/tests/test_project.py b/science_project/tests/test_project.py new file mode 100644 index 0000000..1f3b49a --- /dev/null +++ b/science_project/tests/test_project.py @@ -0,0 +1,6 @@ +import pytest +from .. import add_one + +@pytest.mark.parametrize("x, y", [(1, 2), (2, 3), (3, 4)]) +def test_add_one(x, y): + assert y == add_one(x) From 7ac36dae28f989040c7e5c23453e97d63a9ac0e6 Mon Sep 17 00:00:00 2001 From: Lars Buntemeyer Date: Mon, 21 Oct 2024 13:25:29 +0200 Subject: [PATCH 2/3] reformat --- science_project/__init__.py | 1 - science_project/tests/test_project.py | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/science_project/__init__.py b/science_project/__init__.py index 543f1ad..aaab658 100644 --- a/science_project/__init__.py +++ b/science_project/__init__.py @@ -1,2 +1 @@ - from .main import add_one diff --git a/science_project/tests/test_project.py b/science_project/tests/test_project.py index 1f3b49a..374b50f 100644 --- a/science_project/tests/test_project.py +++ b/science_project/tests/test_project.py @@ -1,6 +1,7 @@ import pytest from .. import add_one + @pytest.mark.parametrize("x, y", [(1, 2), (2, 3), (3, 4)]) def test_add_one(x, y): assert y == add_one(x) From feeb7a6315858380852fd3025eb457f6c18f607e Mon Sep 17 00:00:00 2001 From: Lars Buntemeyer Date: Mon, 21 Oct 2024 13:29:32 +0200 Subject: [PATCH 3/3] added ci workflow --- .github/workflows/ci.yaml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..2f802c6 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,22 @@ +name: Test my project + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["pypy3.10", "3.9", "3.10", "3.11", "3.12", "3.13"] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + # You can test your matrix by printing the current Python version + - name: Display Python version + run: python -c "import sys; print(sys.version)" +