Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve coverage #270

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .coveragerc

This file was deleted.

11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,19 @@ addopts = [
"--ignore setup.py",
"--ignore run_test.py",
"--cov-report term-missing",
"--cov-branch",
"--tb native",
"--strict-markers",
"--durations=20",
]
markers = ["serial: execute test serially (to avoid race conditions)"]

[tool.coverage.run]
source = [ "src/", ]
omit = [
"setup.py",
"src/conda_package_handling/__main__.py",
"src/conda_package_handling/_version.py",
"versioneer.py",
"tests/*",
]
10 changes: 6 additions & 4 deletions src/conda_package_handling/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from .tarball import CondaTarBZ2 as _CondaTarBZ2
from .utils import ensure_list, filter_info_files
from .utils import get_executor as _get_executor
from .utils import rm_rf as _rm_rf

SUPPORTED_EXTENSIONS: dict[str, type[AbstractBaseFormat]] = {".tar.bz2": _CondaTarBZ2}

Expand Down Expand Up @@ -113,7 +112,7 @@ def create(prefix, file_list, out_fn, out_folder=None, **kw):
# don't leave broken files around
abs_out_fn = _os.path.join(out_folder, out_fn)
if _os.path.isfile(abs_out_fn):
_rm_rf(abs_out_fn)
_os.unlink(abs_out_fn)
raise err
else:
raise ValueError(
Expand Down Expand Up @@ -191,7 +190,7 @@ def is_info(filename):
except BaseException as e:
# don't leave partial package around
if _os.path.isfile(out_fn):
_rm_rf(out_fn)
_os.unlink(out_fn)
if not isinstance(e, Exception):
raise
errors = str(e)
Expand All @@ -216,7 +215,10 @@ def transmute(in_file, out_ext, out_folder=None, processes=1, **kw):
for fn, out_fn, errors in executor.map(convert_f, flist):
if errors:
failed_files[fn] = errors
_rm_rf(out_fn)
try:
_os.unlink(out_fn)
except FileNotFoundError:
pass
return failed_files


Expand Down
7 changes: 4 additions & 3 deletions src/conda_package_handling/streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io
import tarfile
from contextlib import redirect_stdout
from pathlib import Path
from tarfile import TarError
from typing import Generator
from zipfile import BadZipFile
Expand All @@ -18,9 +19,9 @@


def _stream_components(
filename: str,
filename: str | Path,
components: list[str],
dest_dir: str = "",
dest_dir: str | Path = "",
) -> Generator[Generator[tuple[tarfile.TarFile, tarfile.TarInfo]]]:
if str(filename).endswith(".tar.bz2"):
assert components == ["pkg"]
Expand All @@ -38,7 +39,7 @@ def _stream_components(
raise exceptions.InvalidArchiveError(filename, f"failed with error: {str(e)}") from e


def _extract(filename: str, dest_dir: str, components: list[str]):
def _extract(filename: str | Path, dest_dir: str | Path, components: list[str]):
"""
Extract .conda or .tar.bz2 package to dest_dir.

Expand Down
Loading
Loading