Beispiel #1
0
    def test_compress_7zip(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")
        fold = get_temp_folder(__file__, "temp_compress_7zip")
        url = "https://docs.python.org/3.5/library/ftplib.html"
        f = download(url, fold)

        if is_travis_or_appveyor() != "travis":
            out7 = os.path.join(fold, "try.7z")
            r = zip7_files(out7, [f], fLOG=fLOG, temp_folder=fold)
            fLOG(r)
            if not os.path.exists(out7):
                raise FileNotFoundError(out7)
        else:
            warnings.warn(
                "unzipping files with 7z on a is not tested on appveyor")
            return

        if sys.version_info[0] == 2:
            typbytes = bytearray
        else:
            typbytes = bytes

        if is_travis_or_appveyor() == "appveyor":
            warnings.warn(
                "py7zlib.py requires to be updated with the github version")
            return

        from py7zlib import COMPRESSION_METHOD_COPY
        fLOG("***", COMPRESSION_METHOD_COPY)
        res = un7zip_files(out7)
        assert isinstance(res, list)
        self.assertEqual(len(res), 1)
        fLOG(res[0][0])
        if not isinstance(res[0][1], (typbytes, str)):
            raise TypeError(type(res[0][1]))
        assert res[0][0].endswith("ftplib.html")

        fold = get_temp_folder(__file__, "temp_compress_7zip2")
        res = un7zip_files(out7, where_to=fold, fLOG=fLOG)

        if sys.version_info[0] == 2:
            return

        self.assertEqual(len(res), 1)
        s = res[0].replace("\\", "/")
        if not s.endswith("_unittests/ut_filehelper/temp_compress_7zip2/ftplib.html"):
            raise Exception(res[0])
Beispiel #2
0
    def test_uncompress_7zip(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        import pylzma
        # use github version, not pypi version (2016-11-11)
        # this version does not include a fix to read file produced by the
        # latest version of 7z
        assert pylzma

        if is_travis_or_appveyor() == "appveyor":
            warnings.warn(
                "unzipping files with 7z on a is not tested on appveyor")
            return

        fold = get_temp_folder(__file__, "temp_uncompress_7zip")
        data = os.path.join(fold, "..", "data", "ftplib.7z")
        files = un7zip_files(data, where_to=fold, fLOG=fLOG)
        self.assertEqual(len(files), 1)