def test_text_tab_2_to_space(self): path = full_path(self.root_directory, self.files[1]) tshift(path, 3) after_tshift_file = open(path) after_tshift_text = after_tshift_file.read() after_tshift_file.close() self.assertEqual(after_tshift_text, text_space_2)
def test_text_tab_3_to_space_with_listdir(self): before_tshift_files = os.listdir(self.root_directory) expected_files = sorted( os.listdir(self.root_directory) + ['post_tshift_test_3.txt']) path = full_path(self.root_directory, self.files[2]) tshift(path, 6, full_path(self.root_directory, 'post_tshift_test_3.txt')) after_tshift_files = sorted(os.listdir(self.root_directory)) self.assertEqual(after_tshift_files, expected_files)
def test_negative_space_number_fail(self): success, error = tshift(full_path(self.root_directory, self.files[1]), -2) self.assertFalse(success) self.assertEqual('space number should be a non zero positive number', error)
def test_file_exist_fail(self): success, error = tshift(full_path(self.root_directory, 'test_4.txt')) self.assertFalse(success) self.assertRegex(error, r"file ([\"'])(?:(?=(\\?))\2.)*?\1 does not exist")