Skip to content

Commit

Permalink
Fix python tests
Browse files Browse the repository at this point in the history
Signed-off-by: Doug Walker <[email protected]>
  • Loading branch information
doug-walker committed Oct 26, 2024
1 parent aa2d195 commit fc2444f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/bindings/python/apphelpers/PyColorSpaceHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ void bindPyColorSpaceMenuHelpers(py::module & m)
.def("setIncludeNamedTransforms", &ColorSpaceMenuParameters::setIncludeNamedTransforms,
"includeNamedTransforms"_a = true,
DOC(ColorSpaceMenuParameters, setIncludeNamedTransforms))
.def("getTreatNoCategoryAsAny", &ColorSpaceMenuParameters::getTreatNoCategoryAsAny,
DOC(ColorSpaceMenuParameters, getTreatNoCategoryAsAny))
.def("setTreatNoCategoryAsAny", &ColorSpaceMenuParameters::setTreatNoCategoryAsAny,
"treatNoCategoryAsAny"_a = false,
DOC(ColorSpaceMenuParameters, setTreatNoCategoryAsAny))
Expand Down
19 changes: 16 additions & 3 deletions tests/python/ColorSpaceHelpersTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ def test_menu_parameters(self):
encodings = 'video',
searchReferenceSpaceType = OCIO.SEARCH_REFERENCE_SPACE_DISPLAY,
includeRoles = True,
includeNamedTransforms = True)
includeNamedTransforms = True,
treatNoCategoryAsAny = True)
self.assertTrue(params.getConfig())
self.assertEqual(params.getConfig().getCacheID(), self.cfg.getCacheID())
self.assertEqual(params.getRole(), 'role')
Expand All @@ -51,6 +52,7 @@ def test_menu_parameters(self):
self.assertEqual(params.getSearchReferenceSpaceType(), OCIO.SEARCH_REFERENCE_SPACE_DISPLAY)
self.assertTrue(params.getIncludeRoles())
self.assertTrue(params.getIncludeNamedTransforms())
self.assertTrue(params.getTreatNoCategoryAsAny())

params.setRole('')
self.assertEqual(params.getRole(), '')
Expand All @@ -69,8 +71,10 @@ def test_menu_parameters(self):
params.setIncludeRoles(False)
params.setIncludeRoles()
self.assertTrue(params.getIncludeRoles())
params.setIncludeNamedTransforms()
self.assertTrue(params.getIncludeNamedTransforms())
params.setIncludeNamedTransforms(False)
self.assertFalse(params.getIncludeNamedTransforms())
params.setTreatNoCategoryAsAny(False)
self.assertFalse(params.getTreatNoCategoryAsAny())

def test_menu_creation_colorspaces(self):
"""
Expand Down Expand Up @@ -131,6 +135,7 @@ def test_menu_creation_colorspaces(self):
self.assertEqual(str(menu),
'config: 667ca4dc5b3779e570229fb7fd9cffe1:6001c324468d497f99aa06d3014798d8, '
'includeColorSpaces: true, includeRoles: false, includeNamedTransforms: false, '
'treatNoCategoryAsAny: false, '
'color spaces = [raw, lin_1, lin_2, log_1, in_1, in_2, in_3, view_1, view_2, view_3, '
'lut_input_1, lut_input_2, lut_input_3, display_lin_1, display_lin_2, display_log_1]')

Expand Down Expand Up @@ -215,6 +220,14 @@ def test_menu_creation_catgeories(self):
menu = OCIO.ColorSpaceMenuHelper(params)
self.assertEqual(menu.getNumColorSpaces(), 3)

params.setEncodings('')
params.setTreatNoCategoryAsAny(True)
menu = OCIO.ColorSpaceMenuHelper(params)
self.assertEqual(menu.getNumColorSpaces(), 14)
self.assertEqual(menu.getName(0), 'raw')
self.assertEqual(menu.getName(1), 'lin_1')
self.assertEqual(menu.getName(7), 'view_1')

def test_menu_creation_include_roles(self):
"""
Test the constructor() with extra roles.
Expand Down

0 comments on commit fc2444f

Please sign in to comment.