Skip to content

Commit

Permalink
[3.13] pythongh-123930: Correct test of attribute failure to account …
Browse files Browse the repository at this point in the history
…for iOS (pythonGH-125959) (python#125960)

pythongh-123930: Correct test of attribute failure to account for iOS (pythonGH-125959)

Update a test of importing attributes from binary modules to account for iOS conditions.
(cherry picked from commit 75401fe)

Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
  • Loading branch information
miss-islington and freakboy3742 authored Oct 25, 2024
1 parent 32830cf commit b673581
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 @@ -389,10 +389,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 b673581

Please sign in to comment.