Skip to content

gh-123930: Correct test of attribute failure to account for iOS #125959

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading