Skip to content

Commit 7daa3d4

Browse files
[3.12] pythongh-123930: Correct test of attribute failure to account 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 <[email protected]>
1 parent 89a9c81 commit 7daa3d4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Lib/test/test_import/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,10 +365,14 @@ def test_from_import_missing_attr_has_name_and_so_path(self):
365365
from _testcapi import i_dont_exist
366366
self.assertEqual(cm.exception.name, '_testcapi')
367367
if hasattr(_testcapi, "__file__"):
368-
self.assertEqual(cm.exception.path, _testcapi.__file__)
368+
# The path on the exception is strictly the spec origin, not the
369+
# module's __file__. For most cases, these are the same; but on
370+
# iOS, the Framework relocation process results in the exception
371+
# being raised from the spec location.
372+
self.assertEqual(cm.exception.path, _testcapi.__spec__.origin)
369373
self.assertRegex(
370374
str(cm.exception),
371-
r"cannot import name 'i_dont_exist' from '_testcapi' \(.*\.(so|fwork|pyd)\)"
375+
r"cannot import name 'i_dont_exist' from '_testcapi' \(.*(\.(so|pyd))?\)"
372376
)
373377
else:
374378
self.assertEqual(

0 commit comments

Comments
 (0)