Esempio n. 1
0
    def test_path_to_names(self):
        path = "\\firstdir/seconddir/thirdfile"
        comps_info = CPath.to_path_comps_info(path)
        names = comps_info.names
        self.assertEqual(
            ('firstdir', 'seconddir', 'thirdfile'),
            names)  # TODO: should this be changed to tuple from list?
        self.assertEqual(comps_info.drive, '/')

        path_2 = r"firstdir\seconddir/thirdfile"
        names_2 = CPath.to_path_comps_info(path_2).names
        self.assertEqual(('firstdir', 'seconddir', 'thirdfile'), names_2)

        path_3 = r"firstdir\\\seconddir\thirdfile/"
        names_3 = CPath.to_path_comps_info(path_3).names
        self.assertEqual(('firstdir', 'seconddir', 'thirdfile'), names_3)

        path_4 = "/firstdir/seconddir/thirdfile/"
        names_4 = CPath.to_path_comps_info(path_4).names
        self.assertEqual(('firstdir', 'seconddir', 'thirdfile'), names_4)
Esempio n. 2
0
 def test_path_to_names__linux_root(self):
     path = '/'
     comps_info = CPath.to_path_comps_info(path)
     names = comps_info.names
     self.assertSequenceEqual([], names)
     self.assertTrue(comps_info.drive == '/')
Esempio n. 3
0
 def test_path_to_names__empty_path_string(self):
     path1 = ""
     self.assertEqual(tuple(), CPath.to_path_comps_info(path1).names)
Esempio n. 4
0
 def test_path_to_names__spaces_only_path_string(self):
     path2 = "                      \n    "
     self.assertRaises(CFSExceptionInvalidPathName,
                       lambda: CPath.to_path_comps_info(path2))
Esempio n. 5
0
 def test_path_to_names__fs_root_path_name(self):
     path1 = "/"
     comp_info = CPath.to_path_comps_info(path1)
     self.assertEqual(tuple([]), comp_info.names)
     self.assertTrue(comp_info.drive == '/')