testsAndMisc/python_pkg/praca_magisterska_video/tests/test_q23_deeplab.py
Krzysztof kuhy Rudnicki 2545d72710 test: achieve 100% branch coverage across all python_pkg packages
- Add comprehensive tests for all packages (3572 tests, 100% branch coverage)
- Split oversized test files to stay under 500-line limit
- Add per-file ruff ignores for test-appropriate suppressions
- Fix _cache_decks.py to properly convert JSON lists to tuples
- Add session-scoped conftest fixture for logging handler cleanup (Python 3.14)
- Update ruff pre-commit hook to v0.15.2
- Add codespell ignore words for test data
- Add generated output files to .gitignore
2026-03-21 17:51:36 +01:00

75 lines
2.5 KiB
Python

"""Tests for _q23_deeplab module."""
from __future__ import annotations
def test_make_dilated_frame() -> None:
"""_make_dilated_frame generates valid frames at various times."""
from python_pkg.praca_magisterska_video._q23_deeplab import _make_dilated_frame
from python_pkg.praca_magisterska_video._q23_helpers import STEP_DUR, H, W
frame = _make_dilated_frame(0.0)
assert frame.shape == (H, W, 3)
# At time where all 3 grids are visible
frame2 = _make_dilated_frame(STEP_DUR * 0.9)
assert frame2.shape == (H, W, 3)
# Near progress=0 (only first grid)
frame3 = _make_dilated_frame(STEP_DUR * 0.1)
assert frame3.shape == (H, W, 3)
def test_make_dilated_frame_progress_breaks() -> None:
"""Test grid visibility at boundary progress values."""
from python_pkg.praca_magisterska_video._q23_deeplab import _make_dilated_frame
from python_pkg.praca_magisterska_video._q23_helpers import STEP_DUR
# progress < 0.3 for gi=1 -> only first grid
frame = _make_dilated_frame(STEP_DUR * 0.7 * 0.15)
assert frame is not None
# progress < 0.6 for gi=2 -> first two grids
frame2 = _make_dilated_frame(STEP_DUR * 0.7 * 0.45)
assert frame2 is not None
def test_make_aspp_frame() -> None:
"""_make_aspp_frame generates valid frames."""
from python_pkg.praca_magisterska_video._q23_deeplab import _make_aspp_frame
from python_pkg.praca_magisterska_video._q23_helpers import STEP_DUR, H, W
frame = _make_aspp_frame(0.0)
assert frame.shape == (H, W, 3)
# All branches visible
frame2 = _make_aspp_frame(STEP_DUR * 0.9)
assert frame2.shape == (H, W, 3)
# Concat visible but not final_conv
frame3 = _make_aspp_frame(STEP_DUR * 0.7 * 0.7)
assert frame3.shape == (H, W, 3)
def test_make_aspp_frame_phases() -> None:
"""Exercise specific phase thresholds in ASPP animation."""
from python_pkg.praca_magisterska_video._q23_deeplab import _make_aspp_frame
from python_pkg.praca_magisterska_video._q23_helpers import STEP_DUR
# Concat phase boundary (progress > 0.6)
frame = _make_aspp_frame(STEP_DUR * 0.7 * 0.62)
assert frame is not None
# Final conv phase (progress > 0.8)
frame2 = _make_aspp_frame(STEP_DUR * 0.7 * 0.85)
assert frame2 is not None
def test_deeplab_demo() -> None:
"""_deeplab_demo returns slides."""
from python_pkg.praca_magisterska_video._q23_deeplab import _deeplab_demo
slides = _deeplab_demo()
assert isinstance(slides, list)
assert len(slides) == 2