Skip to content

Commit

Permalink
More rigorous tests for dynamic file location.
Browse files Browse the repository at this point in the history
  • Loading branch information
freakboy3742 committed Sep 6, 2023
1 parent 6ccc595 commit 5c9a6f8
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions tests/test_thirdparty.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 5c9a6f8

Please sign in to comment.