def test_simple_roundtrip(self): # FIXME: we compare the loaded json to avoid dealing with encoding # differences when comparing objects, but this is kinda stupid r_ipkg = InstalledPkgDescription(self.sections, self.meta, {}) f = StringIO() r_ipkg._write(f) r_s = f.getvalue() ipkg = InstalledPkgDescription.from_string(r_s) f = StringIO() ipkg._write(f) s = f.getvalue() self.assertEqual(json.loads(r_s), json.loads(s))
def test_simple_roundtrip(self): # FIXME: we compare the loaded json to avoid dealing with encoding # differences when comparing objects, but this is kinda stupid r_build_manifest = BuildManifest(self.sections, self.meta, {}) f = StringIO() r_build_manifest._write(f) r_s = f.getvalue() build_manifest = BuildManifest.from_string(r_s) f = StringIO() build_manifest._write(f) s = f.getvalue() self.assertEqual(json.loads(r_s), json.loads(s))
def from_egg(cls, egg_path): zid = compat.ZipFile(egg_path) try: data = json.loads(zid.read("EGG-INFO/ipkg.info")) return cls.from_json_dict(data) finally: zid.close()
def from_string(cls, s): return cls.__from_data(json.loads(s))