def test_host_log(self): tmp_file, tmp_filename = tempfile.mkstemp() dummy_log = HostLog(tmp_filename) # First write to log dummy_log.write("a\nb\nc") # Read it with open(tmp_filename) as f: s = f.read() etalon = "a\nb\nc\n" self.assertEquals(s, etalon) # Next write dummy_log.write("Yet another string") # Read it with open(tmp_filename) as f: s = f.read() etalon = "a\nb\nc\nYet another string\n" self.assertEquals(s, etalon) # Should not append line end if it already exists dummy_log.write("line break->\n") # Read it with open(tmp_filename) as f: s = f.read() etalon = "a\nb\nc\nYet another string\nline break->\n" self.assertEquals(s, etalon) # Cleanup os.unlink(tmp_filename)