def test_get_dpkg_log_content(self): logfile_dpkg = os.path.join(self.tmpdir, "apt-term.log") # note that we intentionally not have a "Log ended:" here # because this may happen if something crashes power goes # down etc OLD_LOG = dedent("""\ Log started: 2013-01-01 12:00:00 old logfile text """) NEW_LOG = dedent("""\ Log started: 2014-10-28 10:00:00 random logfile_dpkg text Log ended: 2013-01-01 12:20:00 Log started: 2014-10-28 12:21:00 more random logfile_dpkg text Log ended: 2013-01-01 12:30:00 """) with open(logfile_dpkg, "w") as fp: fp.write(OLD_LOG) fp.write("\n") fp.write(NEW_LOG) start_time = LoggingDateTime.from_string("2014-10-28 10:00:00") dpkg_log_content = get_dpkg_log_content(logfile_dpkg, start_time) self.assertEqual(dpkg_log_content, NEW_LOG)