예제 #1
0
 def test_handle_subdir_deletion_gracefully(self, tmpdir):
     tmppath = Path(str(tmpdir))
     io.mkdir(tmppath + 'sub')
     io.mkdir(tmppath + 'sub/dir')
     root = phys.Directory(None, str(tmppath))
     root.dirs[0].dirs
     io.rmdir(tmppath + 'sub/dir')
     io.rmdir(tmppath + 'sub')
     root.force_update()
     try:
         root.dirs
     except fs.InvalidPath:
         self.fail()
예제 #2
0
 def test_handle_subdir_deletion_gracefully(self, tmpdir):
     tmppath = Path(str(tmpdir))
     io.mkdir(tmppath + 'sub')
     io.mkdir(tmppath + 'sub/dir')
     root = phys.Directory(None, str(tmppath))
     root.dirs[0].dirs
     io.rmdir(tmppath + 'sub/dir')
     io.rmdir(tmppath + 'sub')
     root.force_update()
     try:
         root.dirs
     except fs.InvalidPath:
         self.fail()
예제 #3
0
def test_load_from_file_with_invalid_path(tmpdir):
    #This test simulates a load from file resulting in a
    #InvalidPath raise. Other directories must be loaded.
    d1 = Directories()
    d1.add_path(testpath + 'onefile')
    #Will raise InvalidPath upon loading
    p = Path(str(tmpdir.join('toremove')))
    io.mkdir(p)
    d1.add_path(p)
    io.rmdir(p)
    tmpxml = str(tmpdir.join('directories_testunit.xml'))
    d1.save_to_file(tmpxml)
    d2 = Directories()
    d2.load_from_file(tmpxml)
    eq_(1, len(d2))
예제 #4
0
def test_load_from_file_with_invalid_path(tmpdir):
    #This test simulates a load from file resulting in a
    #InvalidPath raise. Other directories must be loaded.
    d1 = Directories()
    d1.add_path(testpath + 'onefile')
    #Will raise InvalidPath upon loading
    p = Path(str(tmpdir.join('toremove')))
    io.mkdir(p)
    d1.add_path(p)
    io.rmdir(p)
    tmpxml = str(tmpdir.join('directories_testunit.xml'))
    d1.save_to_file(tmpxml)
    d2 = Directories()
    d2.load_from_file(tmpxml)
    eq_(1, len(d2))