From 7f1aff97996adee1f5bed1238cf081c1bd62cd24 Mon Sep 17 00:00:00 2001 From: Sean Budd Date: Mon, 2 Dec 2024 11:55:59 +1100 Subject: [PATCH 1/3] Skip Screen Curtain unit test if active --- .../test_magnificationAPI.py | 37 ++++++++++++------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/tests/unit/test_visionEnhancementProviders/test_magnificationAPI.py b/tests/unit/test_visionEnhancementProviders/test_magnificationAPI.py index 819baaebb04..2804014569b 100644 --- a/tests/unit/test_visionEnhancementProviders/test_magnificationAPI.py +++ b/tests/unit/test_visionEnhancementProviders/test_magnificationAPI.py @@ -7,7 +7,7 @@ import unittest -from visionEnhancementProviders.screenCurtain import Magnification, TRANSFORM_BLACK +from visionEnhancementProviders.screenCurtain import Magnification, TRANSFORM_BLACK, MAGCOLOREFFECT class _Test_MagnificationAPI(unittest.TestCase): @@ -19,6 +19,29 @@ def tearDown(self): class Test_ScreenCurtain(_Test_MagnificationAPI): + def _isIdentityMatrix(self, magTransformMatrix: MAGCOLOREFFECT) -> bool: + for i in range(5): + for j in range(5): + if i == j: + if magTransformMatrix.transform[i][j] != 1: + return False + else: + if magTransformMatrix.transform[i][j] != 0: + return False + return True + + def setUp(self): + super().setUp() + resultEffect = Magnification.MagGetFullscreenColorEffect() + if not self._isIdentityMatrix(resultEffect): + # If the resultEffect is not the identity matrix, skip the test. + # This is because a full screen colour effect is already set external to testing. + self.skipTest( + f"resultEffect={resultEffect}, should be identity matrix. " + "Full screen colour effect set external to tests. " + ) + return + def test_setAndConfirmBlackFullscreenColorEffect(self): result = Magnification.MagSetFullscreenColorEffect(TRANSFORM_BLACK) self.assertTrue(result) @@ -32,18 +55,6 @@ def test_setAndConfirmBlackFullscreenColorEffect(self): msg=f"i={i}, j={j}, resultEffect={resultEffect}", ) - def test_getDefaultIdentityFullscreenColorEffect(self): - resultEffect = Magnification.MagGetFullscreenColorEffect() - for i in range(5): - for j in range(5): - with self.subTest(i=i, j=j): - # The transform matrix should be the identity matrix - self.assertEqual( - int(i == j), - resultEffect.transform[i][j], - msg=f"i={i}, j={j}, resultEffect={resultEffect}", - ) - class Test_Mouse(_Test_MagnificationAPI): def test_MagShowSystemCursor(self): From d7fdc891046d3d92077a99950ba510a5cd3ee587 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 2 Dec 2024 00:59:20 +0000 Subject: [PATCH 2/3] Pre-commit auto-fix --- .../test_visionEnhancementProviders/test_magnificationAPI.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/test_visionEnhancementProviders/test_magnificationAPI.py b/tests/unit/test_visionEnhancementProviders/test_magnificationAPI.py index 2804014569b..bbb9ef7d8b8 100644 --- a/tests/unit/test_visionEnhancementProviders/test_magnificationAPI.py +++ b/tests/unit/test_visionEnhancementProviders/test_magnificationAPI.py @@ -38,7 +38,7 @@ def setUp(self): # This is because a full screen colour effect is already set external to testing. self.skipTest( f"resultEffect={resultEffect}, should be identity matrix. " - "Full screen colour effect set external to tests. " + "Full screen colour effect set external to tests. ", ) return From a2bdc55df5e611ddb3cf16c21d65c60b9c052ddf Mon Sep 17 00:00:00 2001 From: Sascha Cowley <16543535+SaschaCowley@users.noreply.github.com> Date: Mon, 2 Dec 2024 12:22:11 +1100 Subject: [PATCH 3/3] Update tests/unit/test_visionEnhancementProviders/test_magnificationAPI.py --- .../test_visionEnhancementProviders/test_magnificationAPI.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/test_visionEnhancementProviders/test_magnificationAPI.py b/tests/unit/test_visionEnhancementProviders/test_magnificationAPI.py index bbb9ef7d8b8..fe46b23d621 100644 --- a/tests/unit/test_visionEnhancementProviders/test_magnificationAPI.py +++ b/tests/unit/test_visionEnhancementProviders/test_magnificationAPI.py @@ -37,7 +37,7 @@ def setUp(self): # If the resultEffect is not the identity matrix, skip the test. # This is because a full screen colour effect is already set external to testing. self.skipTest( - f"resultEffect={resultEffect}, should be identity matrix. " + f"{resultEffect=}, should be identity matrix. " "Full screen colour effect set external to tests. ", ) return