From c208b35c3ae6abce1bfbdfdd38c09508c4b31af6 Mon Sep 17 00:00:00 2001 From: emilcode Date: Wed, 1 Oct 2025 10:58:53 +0000 Subject: [PATCH] [added] pytest added to dependency list in requirements.txt and first unit test for the classifie head has been implemented. --- pyproject.toml | 9 ++++++++- requirements.txt | 3 ++- tests/test_model.py | 0 tests/unit/nightingale/test_classifier_head.py | 13 +++++++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) delete mode 100644 tests/test_model.py create mode 100644 tests/unit/nightingale/test_classifier_head.py diff --git a/pyproject.toml b/pyproject.toml index 09c9949..4074d48 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,4 +15,11 @@ requires-python = ">=3.8" dependencies = [] [tool.setuptools.packages.find] -where = ["src"] \ No newline at end of file +where = ["src"] + +[tool.pytest.ini_options] +minversion = "8.0" +addopts = "-ra -q" +testpaths = [ + "tests" +] \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 29afc90..7edb867 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,4 +15,5 @@ fastapi==0.116.2 uvicorn==0.35.0 python-multipart==0.0.20 sphinx==8.2.3 -sphinx-rtd-theme==3.0.2 \ No newline at end of file +sphinx-rtd-theme==3.0.2 +pytest==8.4.2 \ No newline at end of file diff --git a/tests/test_model.py b/tests/test_model.py deleted file mode 100644 index e69de29..0000000 diff --git a/tests/unit/nightingale/test_classifier_head.py b/tests/unit/nightingale/test_classifier_head.py new file mode 100644 index 0000000..49581b3 --- /dev/null +++ b/tests/unit/nightingale/test_classifier_head.py @@ -0,0 +1,13 @@ +import pytest +from nightingale.model.classifier_head import ClassifierHead +import numpy as np + +@pytest.fixture +def classifier_head(): + return ClassifierHead(num_classes=10) + +def test_classifier_head_forward(classifier_head): + # Test the forward pass + x = np.random.randn(32, 128) + logits = classifier_head(x) + assert logits.shape == (32, 10)