def test_fullpath_with_multi_level_hierarchy(self): root_path = Path(self.root)('.') dirs = ["test", "spam", "egg"] parent = root_path for d in dirs: parent = Path(parent)(d) expected = self.create_path(self.root, *dirs) self.assertPathEqual(expected, parent.fullpath())
def test_is_dir(self): root_path = Path(self.root)('.') self.assertTrue(root_path.is_dir()) dirs = ["test", "spam", "egg"] created_dirs = [ Path(root_path)(d) for d in dirs ] for d in created_dirs: self.assertFalse(d.exists()) os.mkdir(d.fullpath()) self.assertTrue(d.exists()) self.assertTrue(d.is_dir())
def test_is_file(self): root = self.create_basic_filesystem() file_ = Path(root)("FileInRoot") self.assertFalse(root.is_file()) self.assertTrue(file_.is_file())
def test_split_parent_with_path_containing_spaces(self): parent = "Dir with spaces" dirname= "NormalDir" res = Path.split_parent(self.create_path(self.root, parent, dirname)) expected = (self.create_path(self.root,parent), dirname) self.assertEqual(res, expected)
def test_split_parent_with_relative_path(self): parent = "test" dirname = "dirtest" res = Path.split_parent(self.create_path(parent,dirname)) expected = (parent, dirname) self.assertEqual(res, expected)
def test_split_parent_with_file(self): dirname = "test" filename = "fileA" res = Path.split_parent(self.create_path(self.root,dirname,filename)) expected = (self.create_path(self.root, dirname), filename) self.assertEqual(res, expected)
def test_split_parent_with_empty_path(self): res = Path.split_parent("") expected = ("", "") self.assertEqual(res, expected)
def test_split_parent_on_root_path(self): res = Path.split_parent(self.root) expected = (self.root, "") self.assertEqual(res, expected)