From 2399e0dddd5102d0a31990534e8d007d1c8b60dd Mon Sep 17 00:00:00 2001 From: David Perl Date: Mon, 27 Jul 2026 09:08:13 +0200 Subject: [PATCH] test: update tests to use instances --- tests/test_aare_exception.py | 73 ++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/tests/test_aare_exception.py b/tests/test_aare_exception.py index 4b775eb..cf7c6f4 100644 --- a/tests/test_aare_exception.py +++ b/tests/test_aare_exception.py @@ -9,7 +9,6 @@ These cover: from __future__ import annotations -import pytest from aarecommon.errors.exception_handler import ( AareAuthError, AareDBCommunicationError, @@ -57,48 +56,50 @@ from aarecommon.errors.exception_handler import ( def test_aare_exception_class_critical_default_false(): - assert AareException.critical is False + assert AareException().critical is False def test_phase3_classes_have_critical_default_true(): - for cls in ( - TellCommunicationError, - TellConnectionException, - CriticalTellException, - SmargonCommunicationError, - AerotechCommunicationError, - JFJochCommunicationError, - BECCommunicationError, - StateTransitionFailed, - MaintenanceStateException, - BeamlineBusyException, - BeamlineBusyTimeoutException, - MagnetPositionSensorError, - SmartMagnetFaultException, - TransformationInvalidException, + for e in ( + TellCommunicationError(), + TellConnectionException(), + CriticalTellException(), + SmargonCommunicationError(), + AerotechCommunicationError(), + JFJochCommunicationError(), + BECCommunicationError(), + StateTransitionFailed(), + MaintenanceStateException(), + BeamlineBusyException(), + BeamlineBusyTimeoutException(), + MagnetPositionSensorError(), + SmartMagnetFaultException(), + TransformationInvalidException(), ): - assert cls.critical is True, f"{cls.__name__} should default to critical=True in Phase 3" + assert e.critical is True, ( + f"{e.__class__.__name__} should default to critical=True in Phase 3" + ) def test_other_core_classes_keep_critical_default_false(): - for cls in ( - AutomationError, - AareUserError, - AareAuthError, - TellException, - SmargonException, - AerotechException, - JFJochException, - BECException, - BeamlineStateException, - MountingFailed, - UnmountingFailed, - LoopCenteringFailed, - TellCommandWhileBusyException, - WarningTellException, - AareDBCommunicationError, + for e in ( + AutomationError(), + AareUserError(), + AareAuthError(), + TellException(), + SmargonException(), + AerotechException(), + JFJochException(), + BECException(), + BeamlineStateException(), + MountingFailed(), + UnmountingFailed(), + LoopCenteringFailed(), + TellCommandWhileBusyException(), + WarningTellException(), + AareDBCommunicationError(), ): - assert cls.critical is False, f"{cls.__name__} should remain critical=False" + assert e.critical is False, f"{e.__class__.__name__} should remain critical=False" # --------------------------------------------------------------------------- @@ -110,7 +111,7 @@ def test_instance_critical_override_true(): exc = MountingFailed("mount fail", critical=True) assert exc.critical is True # class default unchanged - assert MountingFailed.critical is False + assert MountingFailed().critical is False def test_instance_critical_override_false():