本文整理汇总了Python中Twitter_Utils.EternalProcess.EternalProcess.remove_last_line_from_file方法的典型用法代码示例。如果您正苦于以下问题:Python EternalProcess.remove_last_line_from_file方法的具体用法?Python EternalProcess.remove_last_line_from_file怎么用?Python EternalProcess.remove_last_line_from_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Twitter_Utils.EternalProcess.EternalProcess
的用法示例。
在下文中一共展示了EternalProcess.remove_last_line_from_file方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_remove_last_line_from_file
# 需要导入模块: from Twitter_Utils.EternalProcess import EternalProcess [as 别名]
# 或者: from Twitter_Utils.EternalProcess.EternalProcess import remove_last_line_from_file [as 别名]
def test_remove_last_line_from_file(self):
eternal_process = EternalProcess()
path = os.getcwd() + '/Twitter_Utils/data/tweets/base_tweets_for_tests/base_tweets_for_tests.txt'
count_1 = 0
with open(path, 'r') as reader:
for _ in reader:
count_1 += 1
reader.close()
self.assertIs(True, eternal_process.remove_last_line_from_file(path))
count_2 = 0
with open(path, 'r') as reader:
for _ in reader:
count_2 += 1
reader.close()
self.assertEqual(count_1-1, count_2)
示例2: test_remove_last_line_from_file_raises_ioerror
# 需要导入模块: from Twitter_Utils.EternalProcess import EternalProcess [as 别名]
# 或者: from Twitter_Utils.EternalProcess.EternalProcess import remove_last_line_from_file [as 别名]
def test_remove_last_line_from_file_raises_ioerror(self):
eternal_process = EternalProcess()
path = os.getcwd() + '/Twitter_Utils/data/tweets/not_a_real_path/not_a_real_path.txt'
self.assertIs(False, eternal_process.remove_last_line_from_file(path))