From 5c9a6f8bab29f6115ea4765e45c09b84f880ce80 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Wed, 6 Sep 2023 09:00:16 +0800 Subject: [PATCH] More rigorous tests for dynamic file location. --- tests/test_thirdparty.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tests/test_thirdparty.py b/tests/test_thirdparty.py index 12538fa..74561b5 100644 --- a/tests/test_thirdparty.py +++ b/tests/test_thirdparty.py @@ -10,16 +10,30 @@ def test_module_paths(): "Third party binary modules have meaningful __file__ attributes" + import decimal + + import _decimal + import lru import PIL from PIL import _imaging # iOS and Android both play shenanigans with binary locations. # Make sure the __file__ attribute on the binary module reflects - # the actual location in the file system. The base PIL module is - # pure Python; the binary module for PIL._imaging should be in - # the same folder. + # the actual location in the file system. + # decimal is in the standard library; it is backed by a binary module in the + # lib-dynload folder. + assert ( + Path(_decimal.__file__).parent == Path(decimal.__file__).parent / "lib-dynload" + ) + + # The base PIL module is an __init__.py that is pure Python; the binary module for + # PIL._imaging should be in the same folder. assert Path(_imaging.__file__).parent == Path(PIL.__file__).parent + # lru is an extension module that is at the root of the app_packages folder. + # The app_packages folder is the one that holds PIL. + assert Path(lru.__file__).parent == Path(PIL.__file__).parent.parent + @pytest.mark.skipif(sys.platform == "win32", reason="cffi not available on windows") def test_cffi():