Skip to content

Commit

Permalink
gh-123930: Correct test of attribute failure to account for iOS (#125959
Browse files Browse the repository at this point in the history
)

Update a test of importing attributes from binary modules to account for iOS conditions.
  • Loading branch information
freakboy3742 authored Oct 25, 2024
1 parent 2513593 commit 75401fe
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Lib/test/test_import/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,14 @@ def test_from_import_missing_attr_has_name_and_so_path(self):
from _testcapi import i_dont_exist
self.assertEqual(cm.exception.name, '_testcapi')
if hasattr(_testcapi, "__file__"):
self.assertEqual(cm.exception.path, _testcapi.__file__)
# The path on the exception is strictly the spec origin, not the
# module's __file__. For most cases, these are the same; but on
# iOS, the Framework relocation process results in the exception
# being raised from the spec location.
self.assertEqual(cm.exception.path, _testcapi.__spec__.origin)
self.assertRegex(
str(cm.exception),
r"cannot import name 'i_dont_exist' from '_testcapi' \(.*\.(so|fwork|pyd)\)"
r"cannot import name 'i_dont_exist' from '_testcapi' \(.*(\.(so|pyd))?\)"
)
else:
self.assertEqual(
Expand Down

0 comments on commit 75401fe

Please sign in to comment.