def test_valid_file_path(self): ''' Tests behavior with a 100% valid path to a file. ''' output = path_utils.valid_split(__file__) expected_output = os.path.split(__file__) self.assertEqual(output, expected_output)
def test_valid_dir_path(self): ''' Tests behavior with a 100% valid path to a directory. ''' test_path = os.path.dirname(__file__) output = path_utils.valid_split(test_path) expected_output = os.path.split(test_path) self.assertEqual(output, expected_output)
def test_invalid_path(self): ''' Tests behavior with a 100% invalid path. ''' test_path = path_utils.versioned_name('', 'foo') output = path_utils.valid_split(test_path) expected_output = ('', test_path) self.assertEqual(output, expected_output)
def test_invalid_basename(self): ''' Tests the behavior where the basename is invalid. ''' dirname = os.path.dirname(__file__) test_path = path_utils.versioned_name(dirname, 'foo') output = path_utils.valid_split(test_path) expected_output = (dirname, os.path.basename(test_path)) self.assertEqual(output, expected_output)
def test_invalid_multiple_basenames(self): ''' Tests the behavior where multiple components at the end of the path are invalid. ''' dirname = os.path.dirname(__file__) dirname2 = path_utils.versioned_name(dirname, 'foo') test_path = path_utils.versioned_name(dirname2, 'goo') output = path_utils.valid_split(test_path) expected_output = (dirname, os.path.basename(dirname2)) self.assertEqual(output, expected_output)