def test_save(self): history = History() history.entries = [] for line in ["#1", "#2", "#3", "#4"]: history.append_to(history.entries, line) # save only last 2 lines history.save(self.filename, self.encoding, lines=2) # empty the list of entries and load again from the file history.entries = [""] history.load(self.filename, self.encoding) self.assertEqual(history.entries, ["#3", "#4"])
def test_save(self): history = History() history.entries = [] for line in ['#1', '#2', '#3', '#4']: history.append_to(history.entries, line) # save only last 2 lines history.save(self.filename, self.encoding, lines=2) # empty the list of entries and load again from the file history.entries = [''] history.load(self.filename, self.encoding) self.assertEqual(history.entries, ['#3', '#4'])