# 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
class TestArchive:
    TAR_GZ: str = 'archive.tar.gz'
    TGZ: str = 'archive.tgz'
    TAR_XZ: str = 'archive.tar.xz'
    TAR_BZ2: str = 'archive.tar.bz2'
    ZIP: str = 'archive.zip'
    BZ2: str = 'file.txt.bz2'
    CRATE: str = 'archive.crate'
    GEM: str = 'archive.gem'
    INVALID_TAR_BZ2: str = 'archive-invalid.tar.bz2'
    INVALID_TAR_XZ: str = 'archive-invalid.tar.xz'

    ARCHIVED_FILE: str = 'file.txt'
    ARCHIVED_FILE_CONTENT: str = 'simple testing file'

    TEST_FILES: List[str] = [os.path.join('archives', archive) for archive in [
        TAR_GZ,
        TGZ,
        TAR_XZ,
        TAR_BZ2,
        ZIP,
        BZ2,
        CRATE,
        GEM,
        INVALID_TAR_BZ2,
        INVALID_TAR_XZ,
    ]]

    @pytest.fixture
    def extracted_archive(self, archive, workdir):

# 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

class TestArchive:
    TAR_GZ: str = 'archive.tar.gz'
    TGZ: str = 'archive.tgz'
    TAR_XZ: str = 'archive.tar.xz'
    TAR_BZ2: str = 'archive.tar.bz2'
    ZIP: str = 'archive.zip'
    BZ2: str = 'file.txt.bz2'
    CRATE: str = 'archive.crate'
    GEM: str = 'archive.gem'
    INVALID_TAR_BZ2: str = 'archive-invalid.tar.bz2'
    INVALID_TAR_XZ: str = 'archive-invalid.tar.xz'

    ARCHIVED_FILE: str = 'file.txt'
    ARCHIVED_FILE_CONTENT: str = 'simple testing file'

    TEST_FILES: List[str] = [os.path.join('archives', archive) for archive in [
        TAR_GZ,
        TGZ,
        TAR_XZ,
        TAR_BZ2,
        ZIP,
        BZ2,
        CRATE,
        GEM,
        INVALID_TAR_BZ2,
        INVALID_TAR_XZ,
    ]]

    @pytest.fixture
    def extracted_archive(self, archive, workdir):

        a = Archive(archive)