From 56ee6eb4fffc4ab2e6c5c2906a3f54788f714f72 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 12 Jul 2024 16:48:23 -0700 Subject: [PATCH] Add full set of new tests --- .../importlib_editable/CMakeLists.txt | 9 + .../importlib_editable/pkg/CMakeLists.txt | 8 + .../importlib_editable/pkg/__init__.py | 3 + tests/packages/importlib_editable/pkg/pkg.c | 25 +++ tests/packages/importlib_editable/pkg/pure.py | 2 + .../pkg/subpkg1/CMakeLists.txt | 5 + .../pkg/subpkg1/__init__.py | 3 + .../importlib_editable/pkg/subpkg1/pure.py | 2 + .../importlib_editable/pkg/subpkg1/subpkg1.c | 25 +++ .../pkg/subpkg2/CMakeLists.txt | 8 + .../pkg/subpkg2/__init__.py | 3 + .../importlib_editable/pkg/subpkg2/pure.py | 2 + .../importlib_editable/pkg/subpkg2/subpkg2.c | 25 +++ .../pkg/subpkg2/subsubpkg1/CMakeLists.txt | 6 + .../pkg/subpkg2/subsubpkg1/__init__.py | 3 + .../pkg/subpkg2/subsubpkg1/pure.py | 2 + .../pkg/subpkg2/subsubpkg1/subsubpkg1.c | 25 +++ .../pkg/subpkg2/subsubpkg2/CMakeLists.txt | 6 + .../pkg/subpkg2/subsubpkg2/__init__.py | 3 + .../pkg/subpkg2/subsubpkg2/pure.py | 2 + .../pkg/subpkg2/subsubpkg2/subsubpkg2.c | 25 +++ .../importlib_editable/pyproject.toml | 10 + tests/test_editable.py | 188 ++++++++++++++++++ 23 files changed, 390 insertions(+) create mode 100644 tests/packages/importlib_editable/CMakeLists.txt create mode 100644 tests/packages/importlib_editable/pkg/CMakeLists.txt create mode 100644 tests/packages/importlib_editable/pkg/__init__.py create mode 100644 tests/packages/importlib_editable/pkg/pkg.c create mode 100644 tests/packages/importlib_editable/pkg/pure.py create mode 100644 tests/packages/importlib_editable/pkg/subpkg1/CMakeLists.txt create mode 100644 tests/packages/importlib_editable/pkg/subpkg1/__init__.py create mode 100644 tests/packages/importlib_editable/pkg/subpkg1/pure.py create mode 100644 tests/packages/importlib_editable/pkg/subpkg1/subpkg1.c create mode 100644 tests/packages/importlib_editable/pkg/subpkg2/CMakeLists.txt create mode 100644 tests/packages/importlib_editable/pkg/subpkg2/__init__.py create mode 100644 tests/packages/importlib_editable/pkg/subpkg2/pure.py create mode 100644 tests/packages/importlib_editable/pkg/subpkg2/subpkg2.c create mode 100644 tests/packages/importlib_editable/pkg/subpkg2/subsubpkg1/CMakeLists.txt create mode 100644 tests/packages/importlib_editable/pkg/subpkg2/subsubpkg1/__init__.py create mode 100644 tests/packages/importlib_editable/pkg/subpkg2/subsubpkg1/pure.py create mode 100644 tests/packages/importlib_editable/pkg/subpkg2/subsubpkg1/subsubpkg1.c create mode 100644 tests/packages/importlib_editable/pkg/subpkg2/subsubpkg2/CMakeLists.txt create mode 100644 tests/packages/importlib_editable/pkg/subpkg2/subsubpkg2/__init__.py create mode 100644 tests/packages/importlib_editable/pkg/subpkg2/subsubpkg2/pure.py create mode 100644 tests/packages/importlib_editable/pkg/subpkg2/subsubpkg2/subsubpkg2.c create mode 100644 tests/packages/importlib_editable/pyproject.toml diff --git a/tests/packages/importlib_editable/CMakeLists.txt b/tests/packages/importlib_editable/CMakeLists.txt new file mode 100644 index 00000000..0863d78e --- /dev/null +++ b/tests/packages/importlib_editable/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.15...3.26) +project(${SKBUILD_PROJECT_NAME} LANGUAGES C) + +find_package( + Python + COMPONENTS Interpreter Development.Module + REQUIRED) + +add_subdirectory(pkg) diff --git a/tests/packages/importlib_editable/pkg/CMakeLists.txt b/tests/packages/importlib_editable/pkg/CMakeLists.txt new file mode 100644 index 00000000..0a07d102 --- /dev/null +++ b/tests/packages/importlib_editable/pkg/CMakeLists.txt @@ -0,0 +1,8 @@ +python_add_library(pkg MODULE pkg.c WITH_SOABI) + +install(TARGETS pkg DESTINATION pkg/) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/testfile" "This is the file") +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/testfile" DESTINATION pkg/) + +add_subdirectory(subpkg1) +add_subdirectory(subpkg2) diff --git a/tests/packages/importlib_editable/pkg/__init__.py b/tests/packages/importlib_editable/pkg/__init__.py new file mode 100644 index 00000000..931c3ff1 --- /dev/null +++ b/tests/packages/importlib_editable/pkg/__init__.py @@ -0,0 +1,3 @@ +from . import pure, subpkg1, subpkg2 + +__all__ = ["pure", "subpkg1", "subpkg2"] diff --git a/tests/packages/importlib_editable/pkg/pkg.c b/tests/packages/importlib_editable/pkg/pkg.c new file mode 100644 index 00000000..6a303da3 --- /dev/null +++ b/tests/packages/importlib_editable/pkg/pkg.c @@ -0,0 +1,25 @@ +#define PY_SSIZE_T_CLEAN +#include + +float square(float x) { return x * x; } + +static PyObject *square_wrapper(PyObject *self, PyObject *args) { + float input, result; + if (!PyArg_ParseTuple(args, "f", &input)) { + return NULL; + } + result = square(input); + return PyFloat_FromDouble(result); +} + +static PyMethodDef pkg_methods[] = { + {"square", square_wrapper, METH_VARARGS, "Square function"}, + {NULL, NULL, 0, NULL}}; + +static struct PyModuleDef pkg_module = {PyModuleDef_HEAD_INIT, "pkg", + NULL, -1, pkg_methods}; + +/* name here must match extension name, with PyInit_ prefix */ +PyMODINIT_FUNC PyInit_pkg(void) { + return PyModule_Create(&pkg_module); +} diff --git a/tests/packages/importlib_editable/pkg/pure.py b/tests/packages/importlib_editable/pkg/pure.py new file mode 100644 index 00000000..caf28fe9 --- /dev/null +++ b/tests/packages/importlib_editable/pkg/pure.py @@ -0,0 +1,2 @@ +def square(x): + return x * x diff --git a/tests/packages/importlib_editable/pkg/subpkg1/CMakeLists.txt b/tests/packages/importlib_editable/pkg/subpkg1/CMakeLists.txt new file mode 100644 index 00000000..1696ad76 --- /dev/null +++ b/tests/packages/importlib_editable/pkg/subpkg1/CMakeLists.txt @@ -0,0 +1,5 @@ +python_add_library(subpkg1 MODULE subpkg1.c WITH_SOABI) + +install(TARGETS subpkg1 DESTINATION pkg/subpkg1) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/testfile" "This is the file") +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/testfile" DESTINATION pkg/subpkg1) diff --git a/tests/packages/importlib_editable/pkg/subpkg1/__init__.py b/tests/packages/importlib_editable/pkg/subpkg1/__init__.py new file mode 100644 index 00000000..888c1dc3 --- /dev/null +++ b/tests/packages/importlib_editable/pkg/subpkg1/__init__.py @@ -0,0 +1,3 @@ +from . import pure + +__all__ = ["pure"] diff --git a/tests/packages/importlib_editable/pkg/subpkg1/pure.py b/tests/packages/importlib_editable/pkg/subpkg1/pure.py new file mode 100644 index 00000000..caf28fe9 --- /dev/null +++ b/tests/packages/importlib_editable/pkg/subpkg1/pure.py @@ -0,0 +1,2 @@ +def square(x): + return x * x diff --git a/tests/packages/importlib_editable/pkg/subpkg1/subpkg1.c b/tests/packages/importlib_editable/pkg/subpkg1/subpkg1.c new file mode 100644 index 00000000..cdfb22cf --- /dev/null +++ b/tests/packages/importlib_editable/pkg/subpkg1/subpkg1.c @@ -0,0 +1,25 @@ +#define PY_SSIZE_T_CLEAN +#include + +float square(float x) { return x * x; } + +static PyObject *square_wrapper(PyObject *self, PyObject *args) { + float input, result; + if (!PyArg_ParseTuple(args, "f", &input)) { + return NULL; + } + result = square(input); + return PyFloat_FromDouble(result); +} + +static PyMethodDef subpkg1_methods[] = { + {"square", square_wrapper, METH_VARARGS, "Square function"}, + {NULL, NULL, 0, NULL}}; + +static struct PyModuleDef subpkg1_module = {PyModuleDef_HEAD_INIT, "subpkg1", + NULL, -1, subpkg1_methods}; + +/* name here must match extension name, with PyInit_ prefix */ +PyMODINIT_FUNC PyInit_subpkg1(void) { + return PyModule_Create(&subpkg1_module); +} diff --git a/tests/packages/importlib_editable/pkg/subpkg2/CMakeLists.txt b/tests/packages/importlib_editable/pkg/subpkg2/CMakeLists.txt new file mode 100644 index 00000000..1a2b9d6b --- /dev/null +++ b/tests/packages/importlib_editable/pkg/subpkg2/CMakeLists.txt @@ -0,0 +1,8 @@ +python_add_library(subpkg2 MODULE subpkg2.c WITH_SOABI) + +install(TARGETS subpkg2 DESTINATION pkg/subpkg2) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/testfile" "This is the file") +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/testfile" DESTINATION pkg/subpkg2) + +add_subdirectory(subsubpkg1) +add_subdirectory(subsubpkg2) diff --git a/tests/packages/importlib_editable/pkg/subpkg2/__init__.py b/tests/packages/importlib_editable/pkg/subpkg2/__init__.py new file mode 100644 index 00000000..e611a3b8 --- /dev/null +++ b/tests/packages/importlib_editable/pkg/subpkg2/__init__.py @@ -0,0 +1,3 @@ +from . import pure, subsubpkg1, subsubpkg2 + +__all__ = ["pure", "subsubpkg1", "subsubpkg2"] diff --git a/tests/packages/importlib_editable/pkg/subpkg2/pure.py b/tests/packages/importlib_editable/pkg/subpkg2/pure.py new file mode 100644 index 00000000..caf28fe9 --- /dev/null +++ b/tests/packages/importlib_editable/pkg/subpkg2/pure.py @@ -0,0 +1,2 @@ +def square(x): + return x * x diff --git a/tests/packages/importlib_editable/pkg/subpkg2/subpkg2.c b/tests/packages/importlib_editable/pkg/subpkg2/subpkg2.c new file mode 100644 index 00000000..4a1e4b48 --- /dev/null +++ b/tests/packages/importlib_editable/pkg/subpkg2/subpkg2.c @@ -0,0 +1,25 @@ +#define PY_SSIZE_T_CLEAN +#include + +float square(float x) { return x * x; } + +static PyObject *square_wrapper(PyObject *self, PyObject *args) { + float input, result; + if (!PyArg_ParseTuple(args, "f", &input)) { + return NULL; + } + result = square(input); + return PyFloat_FromDouble(result); +} + +static PyMethodDef subpkg2_methods[] = { + {"square", square_wrapper, METH_VARARGS, "Square function"}, + {NULL, NULL, 0, NULL}}; + +static struct PyModuleDef subpkg2_module = {PyModuleDef_HEAD_INIT, "subpkg2", + NULL, -1, subpkg2_methods}; + +/* name here must match extension name, with PyInit_ prefix */ +PyMODINIT_FUNC PyInit_subpkg2(void) { + return PyModule_Create(&subpkg2_module); +} diff --git a/tests/packages/importlib_editable/pkg/subpkg2/subsubpkg1/CMakeLists.txt b/tests/packages/importlib_editable/pkg/subpkg2/subsubpkg1/CMakeLists.txt new file mode 100644 index 00000000..812aef4d --- /dev/null +++ b/tests/packages/importlib_editable/pkg/subpkg2/subsubpkg1/CMakeLists.txt @@ -0,0 +1,6 @@ +python_add_library(subsubpkg1 MODULE subsubpkg1.c WITH_SOABI) + +install(TARGETS subsubpkg1 DESTINATION pkg/subpkg2/subsubpkg1) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/testfile" "This is the file") +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/testfile" + DESTINATION pkg/subpkg2/subsubpkg1/) diff --git a/tests/packages/importlib_editable/pkg/subpkg2/subsubpkg1/__init__.py b/tests/packages/importlib_editable/pkg/subpkg2/subsubpkg1/__init__.py new file mode 100644 index 00000000..888c1dc3 --- /dev/null +++ b/tests/packages/importlib_editable/pkg/subpkg2/subsubpkg1/__init__.py @@ -0,0 +1,3 @@ +from . import pure + +__all__ = ["pure"] diff --git a/tests/packages/importlib_editable/pkg/subpkg2/subsubpkg1/pure.py b/tests/packages/importlib_editable/pkg/subpkg2/subsubpkg1/pure.py new file mode 100644 index 00000000..caf28fe9 --- /dev/null +++ b/tests/packages/importlib_editable/pkg/subpkg2/subsubpkg1/pure.py @@ -0,0 +1,2 @@ +def square(x): + return x * x diff --git a/tests/packages/importlib_editable/pkg/subpkg2/subsubpkg1/subsubpkg1.c b/tests/packages/importlib_editable/pkg/subpkg2/subsubpkg1/subsubpkg1.c new file mode 100644 index 00000000..0da41bea --- /dev/null +++ b/tests/packages/importlib_editable/pkg/subpkg2/subsubpkg1/subsubpkg1.c @@ -0,0 +1,25 @@ +#define PY_SSIZE_T_CLEAN +#include + +float square(float x) { return x * x; } + +static PyObject *square_wrapper(PyObject *self, PyObject *args) { + float input, result; + if (!PyArg_ParseTuple(args, "f", &input)) { + return NULL; + } + result = square(input); + return PyFloat_FromDouble(result); +} + +static PyMethodDef subsubpkg1_methods[] = { + {"square", square_wrapper, METH_VARARGS, "Square function"}, + {NULL, NULL, 0, NULL}}; + +static struct PyModuleDef subsubpkg1_module = {PyModuleDef_HEAD_INIT, "subsubpkg1", + NULL, -1, subsubpkg1_methods}; + +/* name here must match extension name, with PyInit_ prefix */ +PyMODINIT_FUNC PyInit_subsubpkg1(void) { + return PyModule_Create(&subsubpkg1_module); +} diff --git a/tests/packages/importlib_editable/pkg/subpkg2/subsubpkg2/CMakeLists.txt b/tests/packages/importlib_editable/pkg/subpkg2/subsubpkg2/CMakeLists.txt new file mode 100644 index 00000000..0ffd74cc --- /dev/null +++ b/tests/packages/importlib_editable/pkg/subpkg2/subsubpkg2/CMakeLists.txt @@ -0,0 +1,6 @@ +python_add_library(subsubpkg2 MODULE subsubpkg2.c WITH_SOABI) + +install(TARGETS subsubpkg2 DESTINATION pkg/subpkg2/subsubpkg2/) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/testfile" "This is the file") +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/testfile" + DESTINATION pkg/subpkg2/subsubpkg2/) diff --git a/tests/packages/importlib_editable/pkg/subpkg2/subsubpkg2/__init__.py b/tests/packages/importlib_editable/pkg/subpkg2/subsubpkg2/__init__.py new file mode 100644 index 00000000..888c1dc3 --- /dev/null +++ b/tests/packages/importlib_editable/pkg/subpkg2/subsubpkg2/__init__.py @@ -0,0 +1,3 @@ +from . import pure + +__all__ = ["pure"] diff --git a/tests/packages/importlib_editable/pkg/subpkg2/subsubpkg2/pure.py b/tests/packages/importlib_editable/pkg/subpkg2/subsubpkg2/pure.py new file mode 100644 index 00000000..caf28fe9 --- /dev/null +++ b/tests/packages/importlib_editable/pkg/subpkg2/subsubpkg2/pure.py @@ -0,0 +1,2 @@ +def square(x): + return x * x diff --git a/tests/packages/importlib_editable/pkg/subpkg2/subsubpkg2/subsubpkg2.c b/tests/packages/importlib_editable/pkg/subpkg2/subsubpkg2/subsubpkg2.c new file mode 100644 index 00000000..de4aa397 --- /dev/null +++ b/tests/packages/importlib_editable/pkg/subpkg2/subsubpkg2/subsubpkg2.c @@ -0,0 +1,25 @@ +#define PY_SSIZE_T_CLEAN +#include + +float square(float x) { return x * x; } + +static PyObject *square_wrapper(PyObject *self, PyObject *args) { + float input, result; + if (!PyArg_ParseTuple(args, "f", &input)) { + return NULL; + } + result = square(input); + return PyFloat_FromDouble(result); +} + +static PyMethodDef subsubpkg2_methods[] = { + {"square", square_wrapper, METH_VARARGS, "Square function"}, + {NULL, NULL, 0, NULL}}; + +static struct PyModuleDef subsubpkg2_module = {PyModuleDef_HEAD_INIT, "subsubpkg2", + NULL, -2, subsubpkg2_methods}; + +/* name here must match extension name, with PyInit_ prefix */ +PyMODINIT_FUNC PyInit_subsubpkg2(void) { + return PyModule_Create(&subsubpkg2_module); +} diff --git a/tests/packages/importlib_editable/pyproject.toml b/tests/packages/importlib_editable/pyproject.toml new file mode 100644 index 00000000..dae7eb5a --- /dev/null +++ b/tests/packages/importlib_editable/pyproject.toml @@ -0,0 +1,10 @@ +[build-system] +requires = ["scikit-build-core"] +build-backend = "scikit_build_core.build" + +[project] +name = "pkg" +version = "0.0.1" + +[tool.scikit-build] +build-dir = "build/{wheel_tag}" diff --git a/tests/test_editable.py b/tests/test_editable.py index 1d54d866..0dfffbdd 100644 --- a/tests/test_editable.py +++ b/tests/test_editable.py @@ -156,3 +156,191 @@ def test_install_dir(isolated): assert "Running cmake" in out assert c_module.exists() assert not failed_c_module.exists() + + +def _setup_package_for_editable_layout_tests( + monkeypatch, tmp_path, editable, editable_mode, isolated +): + editable_flag = ["-e"] if editable else [] + + config_mode_flags = [] + if editable: + config_mode_flags.append(f"--config-settings=editable.mode={editable_mode}") + if editable_mode != "inplace": + config_mode_flags.append("--config-settings=build-dir=build/{wheel_tag}") + + # Use a context so that we only change into the directory up until the point where + # we run the editable install. We do not want to be in that directory when importing + # to avoid importing the source directory instead of the installed package. + with monkeypatch.context() as m: + package = PackageInfo("importlib_editable") + process_package(package, tmp_path, m) + + ninja = [ + "ninja" + for f in isolated.wheelhouse.iterdir() + if f.name.startswith("ninja-") + ] + cmake = [ + "cmake" + for f in isolated.wheelhouse.iterdir() + if f.name.startswith("cmake-") + ] + + isolated.install("pip>23") + isolated.install("scikit-build-core", *ninja, *cmake) + + isolated.install( + "-v", + *config_mode_flags, + "--no-build-isolation", + *editable_flag, + ".", + ) + + +@pytest.mark.compile +@pytest.mark.configure +@pytest.mark.integration +@pytest.mark.parametrize( + ("editable", "editable_mode"), [(False, ""), (True, "redirect"), (True, "inplace")] +) +def test_direct_import(monkeypatch, tmp_path, editable, editable_mode, isolated): + _setup_package_for_editable_layout_tests( # type: ignore[no-untyped-call] + monkeypatch, tmp_path, editable, editable_mode, isolated + ) + isolated.execute( + textwrap.dedent( + """ + import pkg + import pkg.pure + import pkg.subpkg1 + import pkg.subpkg1.pure + import pkg.subpkg2 + import pkg.subpkg2.pure + import pkg.subpkg2.subsubpkg1 + import pkg.subpkg2.subsubpkg1.pure + import pkg.subpkg2.subsubpkg2 + import pkg.subpkg2.subsubpkg2.pure + """ + ) + ) + + +@pytest.mark.compile +@pytest.mark.configure +@pytest.mark.integration +@pytest.mark.parametrize( + ("editable", "editable_mode", "check"), + [ + # Without editable + (False, "", "isinstance(files(pkg), pathlib.Path)"), + (False, "", "any(str(x).endswith('.so') for x in files(pkg).iterdir())"), + (False, "", "isinstance(files(pkg.subpkg1), pathlib.Path)"), + ( + False, + "", + "any(str(x).endswith('.so') for x in files(pkg.subpkg1).iterdir())", + ), + (False, "", "isinstance(files(pkg.subpkg2), pathlib.Path)"), + ( + False, + "", + "any(str(x).endswith('.so') for x in files(pkg.subpkg2).iterdir())", + ), + (False, "", "isinstance(files(pkg.subpkg2.subsubpkg1), pathlib.Path)"), + ( + False, + "", + "any(str(x).endswith('.so') for x in files(pkg.subpkg2.subsubpkg1).iterdir())", + ), + (False, "", "isinstance(files(pkg.subpkg2.subsubpkg2), pathlib.Path)"), + ( + False, + "", + "any(str(x).endswith('.so') for x in files(pkg.subpkg2.subsubpkg2).iterdir())", + ), + # Editable redirect + (True, "redirect", "isinstance(files(pkg), pathlib.Path)"), + pytest.param( + True, + "redirect", + "any(str(x).endswith('.so') for x in files(pkg).iterdir())", + marks=pytest.mark.xfail, + ), + (True, "redirect", "isinstance(files(pkg.subpkg1), pathlib.Path)"), + pytest.param( + True, + "redirect", + "any(str(x).endswith('.so') for x in files(pkg.subpkg1).iterdir())", + marks=pytest.mark.xfail, + ), + (True, "redirect", "isinstance(files(pkg.subpkg2), pathlib.Path)"), + pytest.param( + True, + "redirect", + "any(str(x).endswith('.so') for x in files(pkg.subpkg2).iterdir())", + marks=pytest.mark.xfail, + ), + (True, "redirect", "isinstance(files(pkg.subpkg2.subsubpkg1), pathlib.Path)"), + pytest.param( + True, + "redirect", + "any(str(x).endswith('.so') for x in files(pkg.subpkg2.subsubpkg1).iterdir())", + marks=pytest.mark.xfail, + ), + (True, "redirect", "isinstance(files(pkg.subpkg2.subsubpkg2), pathlib.Path)"), + pytest.param( + True, + "redirect", + "any(str(x).endswith('.so') for x in files(pkg.subpkg2.subsubpkg2).iterdir())", + marks=pytest.mark.xfail, + ), + # Editable inplace + (True, "inplace", "isinstance(files(pkg), pathlib.Path)"), + (True, "inplace", "any(str(x).endswith('.so') for x in files(pkg).iterdir())"), + (True, "inplace", "isinstance(files(pkg.subpkg1), pathlib.Path)"), + ( + True, + "inplace", + "any(str(x).endswith('.so') for x in files(pkg.subpkg1).iterdir())", + ), + (True, "inplace", "isinstance(files(pkg.subpkg2), pathlib.Path)"), + ( + True, + "inplace", + "any(str(x).endswith('.so') for x in files(pkg.subpkg2).iterdir())", + ), + (True, "inplace", "isinstance(files(pkg.subpkg2.subsubpkg1), pathlib.Path)"), + ( + True, + "inplace", + "any(str(x).endswith('.so') for x in files(pkg.subpkg2.subsubpkg1).iterdir())", + ), + (True, "inplace", "isinstance(files(pkg.subpkg2.subsubpkg2), pathlib.Path)"), + ( + True, + "inplace", + "any(str(x).endswith('.so') for x in files(pkg.subpkg2.subsubpkg2).iterdir())", + ), + ], +) +def test_importlib_resources( + monkeypatch, tmp_path, editable, editable_mode, isolated, check +): + _setup_package_for_editable_layout_tests( # type: ignore[no-untyped-call] + monkeypatch, tmp_path, editable, editable_mode, isolated + ) + value = isolated.execute( + textwrap.dedent( + f""" + from importlib.resources import files + from importlib.readers import MultiplexedPath + import pkg + import pathlib + print({check}) + """ + ) + ) + + assert value == "True"