MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenColorIO / test_copy

Method test_copy

tests/python/ConfigTest.py:251–288  ·  view source on GitHub ↗

Test the deepcopy() method.

(self)

Source from the content-addressed store, hash-verified

249class ConfigTest(unittest.TestCase):
250
251 def test_copy(self):
252 """
253 Test the deepcopy() method.
254 """
255 cfg = OCIO.Config.CreateRaw()
256 cfg.setMajorVersion(2)
257 cfg.setMinorVersion(1)
258 cfg.setName('test config')
259 cfg.setDescription('test description')
260
261 cfg.addColorSpace(
262 OCIO.ColorSpace(OCIO.REFERENCE_SPACE_DISPLAY,
263 "display_cs",
264 toReference=OCIO.CDLTransform(sat=1.5)))
265 cfg.addColorSpace(
266 OCIO.ColorSpace(OCIO.REFERENCE_SPACE_SCENE,
267 "raw",
268 isData=True))
269
270 rules = OCIO.FileRules()
271 rules.insertRule(0, 'A', 'raw', '*', 'exr')
272 rules.insertRule(1, 'B', 'display_cs', '*', 'png')
273 cfg.setFileRules(rules)
274
275 other = copy.deepcopy(cfg)
276 self.assertFalse(other is cfg)
277
278 self.assertEqual(other.getMajorVersion(), cfg.getMajorVersion())
279 self.assertEqual(other.getMinorVersion(), cfg.getMinorVersion())
280 self.assertEqual(other.getName(), cfg.getName())
281 self.assertEqual(other.getDescription(), cfg.getDescription())
282 self.assertEqual(list(other.getColorSpaceNames()), list(cfg.getColorSpaceNames()))
283 self.assertEqual(other.getFileRules().getNumEntries(), cfg.getFileRules().getNumEntries())
284
285 # Check that the file rules are not shared between the two config instances.
286 rules.removeRule(0)
287 other.setFileRules(rules)
288 self.assertEqual(other.getFileRules().getNumEntries(), cfg.getFileRules().getNumEntries() - 1)
289
290 def test_shared_views(self):
291 # Test these Config functions: addSharedView, getSharedViews, removeSharedView, clearSharedViews.

Callers

nothing calls this directly

Calls 15

insertRuleMethod · 0.95
removeRuleMethod · 0.95
CreateRawMethod · 0.80
setMajorVersionMethod · 0.80
setMinorVersionMethod · 0.80
CDLTransformMethod · 0.80
FileRulesMethod · 0.80
setNameMethod · 0.45
setDescriptionMethod · 0.45
addColorSpaceMethod · 0.45
ColorSpaceMethod · 0.45
setFileRulesMethod · 0.45

Tested by

no test coverage detected