File: test_convert.py

package info (click to toggle)
python-libarchive-c 5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 908 kB
  • sloc: python: 1,552; makefile: 7
file content (24 lines) | stat: -rw-r--r-- 717 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from libarchive import memory_reader, memory_writer

from . import check_archive, treestat


def test_convert():

    # Collect information on what should be in the archive
    tree = treestat('libarchive')

    # Create an archive of our libarchive/ directory
    buf = bytes(bytearray(1000000))
    with memory_writer(buf, 'gnutar', 'xz') as archive1:
        archive1.add_files('libarchive/')

    # Convert the archive to another format
    buf2 = bytes(bytearray(1000000))
    with memory_reader(buf) as archive1:
        with memory_writer(buf2, 'zip') as archive2:
            archive2.add_entries(archive1)

    # Check the data
    with memory_reader(buf2) as archive2:
        check_archive(archive2, tree)