fix rar test

This commit is contained in:
Timmy Welch 2022-06-06 16:58:27 -07:00
parent b5e6e41043
commit 5bb48cf816
2 changed files with 2 additions and 20 deletions

View File

@ -21,6 +21,7 @@ import pathlib
import re
import unicodedata
from collections import defaultdict
from shutil import which # noqa: F401
from typing import Any, Mapping
import pycountry
@ -77,25 +78,6 @@ def add_to_path(dirname: str) -> None:
os.environ["PATH"] = dirname + os.pathsep + os.environ["PATH"]
def which(program: str) -> str | None:
"""Returns path of the executable, if it exists"""
def is_exe(fpath: str) -> bool:
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
fpath, _ = os.path.split(program)
if fpath:
if is_exe(program):
return program
else:
for path in os.environ["PATH"].split(os.pathsep):
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file
return None
def xlate(data: Any, is_int: bool = False) -> Any:
if data is None or data == "":
return None

View File

@ -89,7 +89,7 @@ archivers = [
comicapi.comicarchive.FolderArchiver,
pytest.param(
comicapi.comicarchive.RarArchiver,
marks=pytest.mark.xfail(not comicapi.comicarchive.rar_support, reason="rar support"),
marks=pytest.mark.xfail(not (comicapi.comicarchive.rar_support and shutil.which("rar")), reason="rar support"),
),
]