fix: guard PyQt6 imports in v7 package for headless CI environments

v7/__init__.py: wrap workers/map_widget/dashboard imports in try/except
so CI runners without PyQt6 can still test models, processing, hardware.

test_v7.py: skip TestPolarToGeographic when PyQt6 unavailable, split
TestV7Init.test_key_exports into core vs PyQt6-dependent assertions.
This commit is contained in:
Jason
2026-04-14 00:27:22 +05:45
parent 063fa081fe
commit 77496ccc88
2 changed files with 35 additions and 20 deletions
+15 -2
View File
@@ -264,6 +264,15 @@ class TestUSBPacketParser(unittest.TestCase):
# Test: v7.workers — polar_to_geographic # Test: v7.workers — polar_to_geographic
# ============================================================================= # =============================================================================
def _pyqt6_available():
try:
import PyQt6.QtCore # noqa: F401
return True
except ImportError:
return False
@unittest.skipUnless(_pyqt6_available(), "PyQt6 not installed")
class TestPolarToGeographic(unittest.TestCase): class TestPolarToGeographic(unittest.TestCase):
def test_north_bearing(self): def test_north_bearing(self):
from v7.workers import polar_to_geographic from v7.workers import polar_to_geographic
@@ -326,10 +335,14 @@ class TestV7Init(unittest.TestCase):
def test_key_exports(self): def test_key_exports(self):
import v7 import v7
# Core exports (no PyQt6 required)
for name in ["RadarTarget", "RadarSettings", "GPSData", for name in ["RadarTarget", "RadarSettings", "GPSData",
"ProcessingConfig", "FT2232HConnection", "ProcessingConfig", "FT2232HConnection",
"RadarProtocol", "RadarProcessor", "RadarProtocol", "RadarProcessor"]:
"RadarDataWorker", "RadarMapWidget", self.assertTrue(hasattr(v7, name), f"v7 missing export: {name}")
# PyQt6-dependent exports — only present when PyQt6 is installed
if _pyqt6_available():
for name in ["RadarDataWorker", "RadarMapWidget",
"RadarDashboard"]: "RadarDashboard"]:
self.assertTrue(hasattr(v7, name), f"v7 missing export: {name}") self.assertTrue(hasattr(v7, name), f"v7 missing export: {name}")
+5 -3
View File
@@ -42,7 +42,9 @@ from .processing import (
apply_pitch_correction, apply_pitch_correction,
) )
# Workers and simulator # Workers, map widget, and dashboard require PyQt6 — import lazily so that
# tests/CI environments without PyQt6 can still access models/hardware/processing.
try:
from .workers import ( from .workers import (
RadarDataWorker, RadarDataWorker,
GPSDataWorker, GPSDataWorker,
@@ -50,17 +52,17 @@ from .workers import (
polar_to_geographic, polar_to_geographic,
) )
# Map widget
from .map_widget import ( from .map_widget import (
MapBridge, MapBridge,
RadarMapWidget, RadarMapWidget,
) )
# Main dashboard
from .dashboard import ( from .dashboard import (
RadarDashboard, RadarDashboard,
RangeDopplerCanvas, RangeDopplerCanvas,
) )
except ImportError: # PyQt6 not installed (e.g. CI headless runner)
pass
__all__ = [ # noqa: RUF022 __all__ = [ # noqa: RUF022
# models # models