Exemple #1
0
    def test_ararchive(self):
        archive = apt_inst.ArArchive(u"data/test_debs/data-tar-xz.deb")

        apt_inst.ArArchive(b"data/test_debs/data-tar-xz.deb")

        archive.extract(u"debian-binary", u"data/tmp")
        archive.extract(b"debian-binary", b"data/tmp")
        archive.extractall(u"data/tmp")
        archive.extractall(b"data/tmp")
        self.assertEqual(archive.extractdata(u"debian-binary"), b"2.0\n")
        self.assertEqual(archive.extractdata(b"debian-binary"), b"2.0\n")
        self.assertTrue(archive.getmember(u"debian-binary"))
        self.assertTrue(archive.getmember(b"debian-binary"))
        self.assertTrue(u"debian-binary" in archive)
        self.assertTrue(b"debian-binary" in archive)
        self.assertTrue(archive[b"debian-binary"])
        self.assertTrue(archive[u"debian-binary"])

        tar = archive.gettar(u"control.tar.xz", "xz")
        tar = archive.gettar(b"control.tar.xz", "xz")

        tar.extractall(self.dir_unicode)
        tar.extractall(self.dir_bytes)
        self.assertRaises(LookupError, tar.extractdata, u"Do-not-exist")
        self.assertRaises(LookupError, tar.extractdata, b"Do-not-exist")
        tar.extractdata(b"control")
        tar.extractdata(u"control")

        apt_inst.TarFile(os.path.join(self.dir_unicode, u"control.tar.xz"))
        apt_inst.TarFile(os.path.join(self.dir_bytes, b"control.tar.xz"))
Exemple #2
0
 def __init__(self, fname):
     self.file = open(fname)
     self.deb = apt_inst.ArArchive(self)