Skip to content

Commit 2f754aa

Browse files
Add docstrings to ML test cases (#46)
1 parent ae8154b commit 2f754aa

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

ml/tests/test_ml_smoke.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ def _warn_not_implemented(feature: str):
3838
class TestMLStructure:
3939

4040
def test_ml_directory_exists(self):
41+
"""ml/ directory must be present at the repo root."""
4142
assert Path("ml").exists(), "ml/ directory must exist"
4243

4344
def test_no_syntax_errors(self):
45+
"""All .py files under ml/ must parse without SyntaxError."""
4446
errors = []
4547
for f in Path("ml").rglob("*.py"):
4648
try:
@@ -57,16 +59,19 @@ def test_no_syntax_errors(self):
5759
class TestMLDependencies:
5860

5961
def test_opencv_importable(self):
62+
"""cv2 (OpenCV) must be importable; warns if not yet installed."""
6063
if not _can_import("cv2"):
6164
_warn_not_implemented("OpenCV (cv2)")
6265
return
6366
import cv2
6467
assert cv2.__version__, "cv2 should expose a version"
6568

6669
def test_numpy_importable(self):
70+
"""numpy must be importable — it is a hard dependency of the ML pipeline."""
6771
assert _can_import("numpy"), "numpy must be importable"
6872

6973
def test_pillow_importable(self):
74+
"""Pillow (PIL) must be importable; warns if not yet installed."""
7075
if not _can_import("PIL"):
7176
_warn_not_implemented("Pillow (PIL)")
7277

@@ -83,6 +88,7 @@ class TestDetectionPipeline:
8388
"""
8489

8590
def _get_pipeline_module(self):
91+
"""Attempt to import the pipeline module from several candidate paths."""
8692
for candidate in ("ml.pipeline", "pipeline", "ml.detector", "detector"):
8793
try:
8894
return importlib.import_module(candidate)
@@ -91,6 +97,7 @@ def _get_pipeline_module(self):
9197
return None
9298

9399
def test_pipeline_module_exists(self):
100+
"""ml/pipeline.py (or equivalent) must be importable."""
94101
mod = self._get_pipeline_module()
95102
if mod is None:
96103
_warn_not_implemented("ml/pipeline.py")
@@ -146,3 +153,4 @@ def test_predict_returns_dict(self):
146153
assert "confidence" in result, "result dict must contain 'confidence'"
147154
assert isinstance(result["confidence"], float), "'confidence' must be a float"
148155
assert 0.0 <= result["confidence"] <= 1.0, "'confidence' must be between 0 and 1"
156+

0 commit comments

Comments
 (0)