Skip to content

Commit

Permalink
Skip Screen Curtain unit test if active (#17467)
Browse files Browse the repository at this point in the history
Follow up to #17413 (comment)

Summary of the issue:
The screen curtain unit tests fail if the screen curtain (or another colour transform e.g. contrast mode) is active.
Instead these test should be skipped.
Alternatively, they could be run in debug mode to do the test without collecting the failure
  • Loading branch information
seanbudd authored Dec 2, 2024
1 parent 83fbd7d commit def6a44
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions tests/unit/test_visionEnhancementProviders/test_magnificationAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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=}, 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)
Expand All @@ -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):
Expand Down

0 comments on commit def6a44

Please sign in to comment.