def testBackupCustomDirectory(self): """"Test doing a backup to a custom directory""" bkup = ebmlib.FileBackupMgr() bkup.SetBackupDirectory(common.GetTempDir()) self.assertTrue(bkup.MakeBackupCopy(__file__)) path = bkup.GetBackupFilename(__file__) self.assertTrue(os.path.exists(path), "Path Fail: %s" % path)
def testWriteUTF8Bom(self): """Test writing a file that has utf8 bom character""" txt = self.utf8_bom_file.Read() self.assertTrue(self.utf8_bom_file.HasBom()) new_path = os.path.join(common.GetTempDir(), ebmlib.GetFileName(self.bpath)) self.utf8_bom_file.SetPath(new_path) # write to test temp dir self.utf8_bom_file.Write(txt) # Open and verify that BOM was correctly written back f = open(new_path, 'rb') ntxt = f.read() f.close() self.assertTrue(ntxt.startswith(codecs.BOM_UTF8)) # Ensure that BOM was only written once tmp = ntxt.lstrip(codecs.BOM_UTF8) self.assertFalse(tmp.startswith(codecs.BOM_UTF8)) tmp = tmp.decode('utf-8') self.assertEquals(txt, tmp)
def setUp(self): self.ddir = common.GetDataDir() self.tdir = common.GetTempDir() self.fpath = common.GetDataFilePath(u'test_read_utf8.txt')
def setUp(self): self._mgr = ed_session.SessionManager(common.GetTempDir()) common.CopyToTempDir(common.GetDataFilePath('__default.session'))