def test_interface(self): cont = OCIO.Context() cont.setSearchPath("testing123") cont.setWorkingDir("/dir/123") self.assertEqual("$4c2d66a612fc25ddd509591e1dead57b", cont.getCacheID()) self.assertEqual("testing123", cont.getSearchPath()) self.assertEqual("/dir/123", cont.getWorkingDir()) cont.setStringVar("TeSt", "foobar") self.assertEqual("foobar", cont.getStringVar("TeSt")) self.assertEqual(1, cont.getNumStringVars()) self.assertEqual("TeSt", cont.getStringVarNameByIndex(0)) cont.loadEnvironment() self.assertNotEqual(0, cont.getNumStringVars()) cont.setStringVar("TEST1", "foobar") self.assertEqual("/foo/foobar/bar", cont.resolveStringVar("/foo/${TEST1}/bar")) cont.clearStringVars() self.assertEqual(0, cont.getNumStringVars()) self.assertEqual(OCIO.Constants.ENV_ENVIRONMENT_LOAD_PREDEFINED, cont.getEnvironmentMode()) cont.setEnvironmentMode(OCIO.Constants.ENV_ENVIRONMENT_LOAD_ALL) self.assertEqual(OCIO.Constants.ENV_ENVIRONMENT_LOAD_ALL, cont.getEnvironmentMode()) try: cont.setSearchPath("testing123") foo = cont.resolveFileLocation("test.lut") print(foo) except OCIO.ExceptionMissingFile as e: #print e pass
def test_copy(self): """ Test the deepcopy() method. """ cont = OCIO.Context() cont.setSearchPath('testing123:testing456') cont.setWorkingDir('/dir/123') cont.setEnvironmentMode(OCIO.ENV_ENVIRONMENT_LOAD_PREDEFINED) cont['TeSt'] = 'foobar' cont['Bar'] = 'Foo' other = copy.deepcopy(cont) self.assertFalse(other is cont) self.assertEqual(other.getCacheID(), cont.getCacheID()) self.assertEqual(other.getSearchPath(), cont.getSearchPath()) self.assertEqual(other.getWorkingDir(), cont.getWorkingDir()) self.assertEqual(other.getEnvironmentMode(), cont.getEnvironmentMode()) self.assertEqual(list(other), list(cont))
def test_interface(self): """ Construct and use Context. """ cont = OCIO.Context() cont.setSearchPath('testing123') cont.setWorkingDir('/dir/123') self.assertEqual('$4c2d66a612fc25ddd509591e1dead57b', cont.getCacheID()) self.assertEqual('testing123', cont.getSearchPath()) self.assertEqual('/dir/123', cont.getWorkingDir()) cont['TeSt'] = 'foobar' self.assertEqual('foobar', cont['TeSt']) self.assertEqual(1, len(cont)) cont_iter = iter(cont) self.assertEqual(len(cont_iter), 1) self.assertEqual(cont_iter[0], 'TeSt') cont.loadEnvironment() self.assertEqual(len(cont), 1) cont['TEST1'] = 'foobar' self.assertEqual(len(cont), 2) self.assertEqual('/foo/foobar/bar', cont.resolveStringVar('/foo/${TEST1}/bar')) cont.clearStringVars() self.assertEqual(len(cont), 0) self.assertEqual(OCIO.ENV_ENVIRONMENT_LOAD_PREDEFINED, cont.getEnvironmentMode()) cont.setEnvironmentMode(OCIO.ENV_ENVIRONMENT_LOAD_ALL) self.assertEqual(OCIO.ENV_ENVIRONMENT_LOAD_ALL, cont.getEnvironmentMode()) cont.clearSearchPaths() sp = cont.getSearchPaths() self.assertEqual(len(sp), 0) cont.addSearchPath('First/ Path') self.assertEqual(len(sp), 1) cont.addSearchPath('D:\\Second\\Path\\') self.assertEqual(len(sp), 2) self.assertEqual(next(sp), 'First/ Path') self.assertEqual(next(sp), 'D:\\Second\\Path\\') cont.setSearchPath('testing123') with self.assertRaises(OCIO.ExceptionMissingFile): foo = cont.resolveFileLocation('test.lut')
def test_interface(self): cont = OCIO.Context() cont.setSearchPath("testing123") cont.setWorkingDir("/dir/123") self.assertEqual("$af84c0ff921e48843d711a761e05b80f", cont.getCacheID()) self.assertEqual("testing123", cont.getSearchPath()) self.assertEqual("/dir/123", cont.getWorkingDir()) cont.setStringVar("TeSt", "foobar") self.assertEqual("foobar", cont.getStringVar("TeSt")) self.assertEqual(1, cont.getNumStringVars()) self.assertEqual("TeSt", cont.getStringVarNameByIndex(0)) cont.loadEnvironment() self.assertNotEqual(0, cont.getNumStringVars()) cont.setStringVar("TEST1", "foobar") self.assertEqual("/foo/foobar/bar", cont.resolveStringVar("/foo/${TEST1}/bar")) try: cont.setSearchPath("testing123") foo = cont.resolveFileLocation("test.lut") print foo except OCIO.ExceptionMissingFile, e: #print e pass