# Path: rebasehelper/archive.py
# class Archive:
#     """Class representing an archive with sources"""
# 
#     def __init__(self, filename):
#         self._filename = filename
#         self._archive_type = None
# 
#         for archive_type in archive_types.values():
#             if archive_type.match(self._filename):
#                 self._archive_type = archive_type
# 
#         if self._archive_type is None:
#             raise NotImplementedError('Unsupported archive type')
# 
#     def extract_archive(self, path):
#         """
#         Extracts the archive into the given path
# 
#         :param path: Path where to extract the archive to.
#         """
#         logger.verbose('Extracting %s to %s', self._filename, path)
# 
#         try:
#             archive = self._archive_type.open(self._filename)
#         except (EOFError, tarfile.ReadError, lzma.LZMAError) as e:
#             raise IOError(str(e)) from e
# 
#         try:
#             self._archive_type.extract(archive, self._filename, path)
#         finally:
#             archive.close()
# 
#     @classmethod
#     def get_supported_archives(cls):
#         return archive_types.keys()
# 
# Path: rebasehelper/constants.py
# ENCODING: str = locale.getpreferredencoding()


import os
import pytest  # type: ignore
from typing import List
from rebasehelper.archive import Archive
from rebasehelper.constants import ENCODING
            # append top level dir
            d = os.path.join(d, 'archive')
        return d

    @pytest.mark.parametrize('archive', [
        TAR_GZ,
        TGZ,
        TAR_XZ,
        TAR_BZ2,
        BZ2,
        ZIP,
        CRATE,
        GEM,
    ], ids=[
        'tar.gz',
        'tgz',
        'tar.xz',
        'tar.bz2',
        'bz2',
        'zip',
        'crate',
        'gem',
    ])
    def test_archive(self, extracted_archive):
        extracted_file = os.path.join(extracted_archive, self.ARCHIVED_FILE)
        #  check if the dir was created
        assert os.path.isdir(extracted_archive)
        #  check if the file was extracted
        assert os.path.isfile(extracted_file)
        #  check the content

# Path: rebasehelper/archive.py
# class Archive:
#     """Class representing an archive with sources"""
# 
#     def __init__(self, filename):
#         self._filename = filename
#         self._archive_type = None
# 
#         for archive_type in archive_types.values():
#             if archive_type.match(self._filename):
#                 self._archive_type = archive_type
# 
#         if self._archive_type is None:
#             raise NotImplementedError('Unsupported archive type')
# 
#     def extract_archive(self, path):
#         """
#         Extracts the archive into the given path
# 
#         :param path: Path where to extract the archive to.
#         """
#         logger.verbose('Extracting %s to %s', self._filename, path)
# 
#         try:
#             archive = self._archive_type.open(self._filename)
#         except (EOFError, tarfile.ReadError, lzma.LZMAError) as e:
#             raise IOError(str(e)) from e
# 
#         try:
#             self._archive_type.extract(archive, self._filename, path)
#         finally:
#             archive.close()
# 
#     @classmethod
#     def get_supported_archives(cls):
#         return archive_types.keys()
# 
# Path: rebasehelper/constants.py
# ENCODING: str = locale.getpreferredencoding()


# Path: rebasehelper/tests/test_archive.py
import os
import pytest  # type: ignore
from typing import List
from rebasehelper.archive import Archive
from rebasehelper.constants import ENCODING

            # append top level dir
            d = os.path.join(d, 'archive')
        return d

    @pytest.mark.parametrize('archive', [
        TAR_GZ,
        TGZ,
        TAR_XZ,
        TAR_BZ2,
        BZ2,
        ZIP,
        CRATE,
        GEM,
    ], ids=[
        'tar.gz',
        'tgz',
        'tar.xz',
        'tar.bz2',
        'bz2',
        'zip',
        'crate',
        'gem',
    ])
    def test_archive(self, extracted_archive):
        extracted_file = os.path.join(extracted_archive, self.ARCHIVED_FILE)
        #  check if the dir was created
        assert os.path.isdir(extracted_archive)
        #  check if the file was extracted
        assert os.path.isfile(extracted_file)
        #  check the content

        with open(extracted_file, encoding=ENCODING) as f: