Skip to content

Commit

Permalink
tests: importlib_resources: add missing skipif marker
Browse files Browse the repository at this point in the history
It turns out that `test_importlib_resources_namespace_package_data_files`
relies on the behavior of `importlib.resources` that was introduced
in standard library with python 3.10 (and `importlib-resources` >= 5.0).

Add a `@skipif` marker to avoid mysterious test failures when
running on python <= 3.9 without `importlib-resources` installed.
  • Loading branch information
rokm committed Dec 27, 2024
1 parent abaa4de commit fa4cf35
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/functional/test_importlib_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import pytest

from PyInstaller.utils.tests import skipif
from PyInstaller.compat import is_darwin, is_py39, exec_python_rc
from PyInstaller.compat import is_darwin, is_py39, is_py310, exec_python_rc
from PyInstaller.utils.hooks import check_requirement

pytestmark = [
Expand Down Expand Up @@ -88,7 +88,14 @@ def test_importlib_resources_frozen(pyi_builder, script_dir):
# namespace package ends up being handled by PyInstaller's `PyiFrozenFinder`, which requires extra care to ensure
# compatibility with `importlib` resource reader.
# The test covers both scenarios via `as_package` parameter.
#
# NOTE: the handling of resources in PEP-420 namespace packages as expected by this test was introduced in stdlib
# version of `importlib.resources` in python 3.10 (equivalent of importlib-resources >= 5.0).
@pytest.mark.parametrize('as_package', [True, False])
@skipif(
not is_py310 and not check_requirement('importlib_resources >= 5.0'),
reason="Requires python <= 3.10 or importlib_resources >= 5.0."
)
def test_importlib_resources_namespace_package_data_files(pyi_builder, as_package):
pathex = _MODULES_DIR / 'pyi_namespace_package_with_data' / 'package'
hooks_dir = _MODULES_DIR / 'pyi_namespace_package_with_data' / 'hooks'
Expand Down

0 comments on commit fa4cf35

Please sign in to comment.