def test_rm_tree(self): """Test example.rm_tree() using `shutil.rmtree()`.""" self.fs.CreateDirectory('/test/dir1/dir2a') # os.mkdirs() works, too. os.makedirs('/test/dir1/dir2b') self.assertTrue(os.path.isdir('/test/dir1/dir2b')) self.assertTrue(os.path.isdir('/test/dir1/dir2a')) example.rm_tree('/test/dir1') self.assertFalse(os.path.exists('/test/dir1'))
def test_rm_tree(self): '''Test example.rm_tree() `self.fs.CreateDirectory()` creates directories. However, you might prefer the familiar `os.makedirs()`, which also works fine on the fake file system. ''' self.fs.CreateDirectory('/test/dir1/dir2a') # os.mkdirs() works, too. os.makedirs('/test/dir1/dir2b') self.assertTrue(os.path.isdir('/test/dir1/dir2b')) self.assertTrue(os.path.isdir('/test/dir1/dir2a')) example.rm_tree('/test/dir1') self.assertFalse(os.path.exists('/test/dir1'))