Esempio n. 1
0
    def test_targz_noext(self):
        t = TargzFile(f("targz_no_ext"))
        assert t.handles() is True
        assert not t.f.selected
        files = list(t.unpack())
        assert len(files) == 1

        assert files[0].relapath == "foo/bar.txt"
        assert files[0].parentdirs == ["foo"]
        assert files[0].contents == b"hello world\n"
        assert not files[0].password
        assert files[0].magic == "ASCII text"
        assert not files[0].selected
Esempio n. 2
0
    def test_nested_gz(self):
        assert "gzip compr" in f(b"tar_nested.tar.gz").magic
        t = TargzFile(f(b"tar_nested.tar.gz"))
        assert t.handles() is True
        assert not t.f.selected
        files = list(t.unpack())
        assert len(files) == 1

        assert files[0].relapath == b"foo/bar.txt"
        assert files[0].parentdirs == [b"foo"]
        assert files[0].contents == b"hello world\n"
        assert not files[0].password
        assert files[0].magic == "ASCII text"
        assert not files[0].selected
Esempio n. 3
0
    def test_nested_gz(self):
        assert "gzip compr" in f("tar_nested.tar.gz").magic
        t = TargzFile(f("tar_nested.tar.gz"))
        assert t.handles() is True
        assert not t.f.selected
        files = list(t.unpack())
        assert len(files) == 1

        assert files[0].relapath == "foo/bar.txt"
        assert files[0].parentdirs == ["foo"]
        assert files[0].contents == "hello world\n"
        assert not files[0].password
        assert files[0].magic == "ASCII text"
        assert not files[0].selected
Esempio n. 4
0
    def test_nested_gz(self):
        assert "gzip compr" in f("tar_nested.tar.gz").magic
        t = TargzFile(f("tar_nested.tar.gz"))
        assert t.handles() is True
        files = list(t.unpack())
        assert len(files) == 1

        assert files[0].filepath == "foo/bar.txt"
        assert files[0].parentdirs == ["foo"]
        assert files[0].contents == "hello world\n"
        assert not files[0].password
        assert files[0].magic == "ASCII text"

        s = f("tar_nested.tar.gz").get_signature()
        assert s == {"family": "tar", "mode": "r:gz", "unpacker": "targzfile"}
Esempio n. 5
0
 def test_tar_plain2_gz(self):
     assert "gzip compr" in f(b"tar_plain2.tar.gz").magic
     t = TargzFile(f(b"tar_plain2.tar.gz"))
     assert t.handles() is True
     assert not t.f.selected
     files = list(t.unpack())
     assert len(files) == 2
     assert files[0].relapath == b"sflock.txt"
     assert files[0].contents == b"sflock_plain_tar\n"
     assert files[0].magic == "ASCII text"
     assert files[0].parentdirs == []
     assert not files[0].selected
     assert files[1].relapath == b"sflock2.txt"
     assert files[1].contents == b"sflock_plain_tar2\n"
     assert files[1].magic == "ASCII text"
     assert files[1].parentdirs == []
     assert not files[1].selected
Esempio n. 6
0
 def test_tar_plain2_gz(self):
     assert "gzip compr" in f("tar_plain2.tar.gz").magic
     t = TargzFile(f("tar_plain2.tar.gz"))
     assert t.handles() is True
     assert not t.f.selected
     files = list(t.unpack())
     assert len(files) == 2
     assert files[0].relapath == "sflock.txt"
     assert files[0].contents == "sflock_plain_tar\n"
     assert files[0].magic == "ASCII text"
     assert files[0].parentdirs == []
     assert not files[0].selected
     assert files[1].relapath == "sflock2.txt"
     assert files[1].contents == "sflock_plain_tar2\n"
     assert files[1].magic == "ASCII text"
     assert files[1].parentdirs == []
     assert not files[1].selected
Esempio n. 7
0
    def test_tar_plain2_gz(self):
        assert "gzip compr" in f("tar_plain2.tar.gz").magic
        t = TargzFile(f("tar_plain2.tar.gz"))
        assert t.handles() is True
        files = list(t.unpack())
        assert len(files) == 2
        assert files[0].filepath == "sflock.txt"
        assert files[0].contents == "sflock_plain_tar\n"
        assert files[0].magic == "ASCII text"
        assert files[0].parentdirs == []
        assert files[1].filepath == "sflock2.txt"
        assert files[1].contents == "sflock_plain_tar2\n"
        assert files[1].magic == "ASCII text"
        assert files[1].parentdirs == []

        s = f("tar_plain2.tar.gz").get_signature()
        assert s == {"family": "tar", "mode": "r:gz", "unpacker": "targzfile"}