feat(utils): extend import check util (#2820)

* refactor(utils): is_package_available now differentiate between pkg name and module name

* refactor(tests): update require_package decorator
This commit is contained in:
Steven Palma
2026-01-19 16:43:11 +01:00
committed by GitHub
parent fe068df711
commit 5286ef8439
7 changed files with 67 additions and 59 deletions
+2 -2
View File
@@ -167,7 +167,7 @@ def require_package_arg(func):
return wrapper
def require_package(package_name):
def require_package(package_name, import_name=None):
"""
Decorator that skips the test if the specified package is not installed.
"""
@@ -175,7 +175,7 @@ def require_package(package_name):
def decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
if not is_package_available(package_name):
if not is_package_available(pkg_name=package_name, import_name=import_name):
pytest.skip(f"{package_name} not installed")
return func(*args, **kwargs)