def make_pickle(self, *changes, **kwargs): recode_fn = kwargs.pop('recode_fn', None) cm = OldChangeMaster() cm.changes = changes if recode_fn: recode_fn(cm) cPickle.dump(cm, open(self.changes_pickle, "wb"))
def make_pickle(self, *changes, **kwargs): recode_fn = kwargs.pop('recode_fn', None) cm = OldChangeMaster() cm.changes = changes if recode_fn: recode_fn(cm) cPickle.dump(cm, open(self.changes_pickle, "wb"))
def testUTF16Change(self): # Create changes.pck cm = OldChangeMaster() cm.changes = [ Change(who=u"Frosty the \N{SNOWMAN}".encode("utf16"), files=["foo"], comments=u"Frosty the \N{SNOWMAN}".encode("utf16"), branch="b1", revision=12345) ] # instead of running contrib/fix_changes_pickle_encoding.py, we just call # the changemanager's recode_changes directly - it's the function at the # heart of the script anyway. cm.recode_changes('utf16', quiet=True) # and dump the recoded changemanager to changes.pck before trying a schema upgrade cPickle.dump(cm, open(os.path.join(self.basedir, "changes.pck"), "w")) sm = manager.DBSchemaManager(self.spec, self.basedir) sm.upgrade(quiet=True) c = self.db.getChangeNumberedNow(1) self.assertEquals(c.who, u"Frosty the \N{SNOWMAN}") self.assertEquals(c.comments, u"Frosty the \N{SNOWMAN}")
def testUTF16Change(self): # Create changes.pck cm = OldChangeMaster() cm.changes = [ Change( who=u"Frosty the \N{SNOWMAN}".encode("utf16"), files=["foo"], comments=u"Frosty the \N{SNOWMAN}".encode("utf16"), branch="b1", revision=12345, ) ] # instead of running contrib/fix_changes_pickle_encoding.py, we just call # the changemanager's recode_changes directly - it's the function at the # heart of the script anyway. cm.recode_changes("utf16", quiet=True) # and dump the recoded changemanager to changes.pck before trying a schema upgrade cPickle.dump(cm, open(os.path.join(self.basedir, "changes.pck"), "w")) sm = manager.DBSchemaManager(self.spec, self.basedir) sm.upgrade(quiet=True) c = self.db.getChangeNumberedNow(1) self.assertEquals(c.who, u"Frosty the \N{SNOWMAN}") self.assertEquals(c.comments, u"Frosty the \N{SNOWMAN}")