MCPcopy Create free account
hub / github.com/ImageEngine/cortex / testChdir

Method testChdir

test/IECore/IndexedIO.py:243–287  ·  view source on GitHub ↗

Test FileIndexedIO chdir

(self)

Source from the content-addressed store, hash-verified

241 self.assertEqual( l.path() , ["sub4","sub4.1"] )
242
243 def testChdir(self):
244 """Test FileIndexedIO chdir"""
245 f = IECore.FileIndexedIO(os.path.join( ".", "test", "FileIndexedIO.fio" ), [], IECore.IndexedIO.OpenMode.Write)
246 f.subdirectory("sub1", IECore.IndexedIO.MissingBehaviour.CreateIfMissing )
247 f.subdirectory("sub2", IECore.IndexedIO.MissingBehaviour.CreateIfMissing )
248
249 g = f.subdirectory("sub1")
250 self.assertEqual( g.path(), ["sub1"] )
251 self.assertEqual( g.currentEntryId() , "sub1" )
252 self.assertEqual( f.path(), [] )
253 g = f.subdirectory("sub2")
254 self.assertEqual( g.path(), ["sub2"] )
255 self.assertEqual( g.currentEntryId() , "sub2" )
256
257 e = g.subdirectory("sub2.1", IECore.IndexedIO.MissingBehaviour.CreateIfMissing )
258 self.assertEqual( e.path(), ["sub2","sub2.1"] )
259 self.assertEqual( e.currentEntryId() , "sub2.1" )
260 g = e.parentDirectory()
261 self.assertEqual( g.path(), ["sub2"] )
262 self.assertEqual( g.currentEntryId() , "sub2" )
263 f = g.parentDirectory()
264 self.assertEqual( f.path(), [] )
265 self.assertEqual( f.currentEntryId() , "/" )
266 g = f.subdirectory("sub2")
267 self.assertEqual( g.path(), ["sub2"] )
268 self.assertEqual( g.currentEntryId() , "sub2" )
269 e = g.subdirectory("sub2.1")
270 self.assertEqual( e.path(), ["sub2","sub2.1"] )
271 self.assertEqual( e.currentEntryId() , "sub2.1" )
272
273 # test directory function
274 h = f.directory( ["sub2","sub2.1"], IECore.IndexedIO.MissingBehaviour.ThrowIfMissing )
275 self.assertEqual( h.path(), ["sub2","sub2.1"], IECore.IndexedIO.MissingBehaviour.ThrowIfMissing )
276 h = g.directory( ["sub2","sub2.1"], IECore.IndexedIO.MissingBehaviour.ThrowIfMissing )
277 self.assertEqual( h.path(), ["sub2","sub2.1"], IECore.IndexedIO.MissingBehaviour.ThrowIfMissing )
278 h = e.directory( ["sub2","sub2.1"], IECore.IndexedIO.MissingBehaviour.ThrowIfMissing )
279 self.assertEqual( h.path(), ["sub2","sub2.1"], IECore.IndexedIO.MissingBehaviour.ThrowIfMissing )
280
281 # missingBehaviour should default to throw if missing
282 h = e.directory( ["sub2","sub2.1"] )
283 self.assertEqual( h.path(), ["sub2","sub2.1"] )
284 self.assertRaises( RuntimeError, e.directory, [ "i", "dont", "exist" ] )
285 self.assertRaises( RuntimeError, e.subdirectory, "idontexist" )
286 self.assertEqual( None, e.directory( [ "i", "dont", "exist" ], IECore.IndexedIO.MissingBehaviour.NullIfMissing ) )
287 self.assertEqual( None, e.subdirectory( "idontexist", IECore.IndexedIO.MissingBehaviour.NullIfMissing ) )
288
289 def testLs(self):
290 """Test FileIndexedIO ls"""

Callers

nothing calls this directly

Calls 7

FileIndexedIOMethod · 0.80
joinMethod · 0.80
subdirectoryMethod · 0.80
currentEntryIdMethod · 0.80
parentDirectoryMethod · 0.80
pathMethod · 0.45
directoryMethod · 0.45

Tested by

no test coverage detected