https://github.com/python/cpython/commit/b67358125c36c943fb066fdae476c72b34ed57aa
commit: b67358125c36c943fb066fdae476c72b34ed57aa
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: hauntsaninja <[email protected]>
date: 2024-10-25T07:42:20Z
summary:

[3.13] gh-123930: Correct test of attribute failure to account for iOS 
(GH-125959) (#125960)

gh-123930: Correct test of attribute failure to account for iOS (GH-125959)

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

Co-authored-by: Russell Keith-Magee <[email protected]>

files:
M Lib/test/test_import/__init__.py

diff --git a/Lib/test/test_import/__init__.py b/Lib/test/test_import/__init__.py
index fac5265f1758da..3f71a2bf3d9c39 100644
--- a/Lib/test/test_import/__init__.py
+++ b/Lib/test/test_import/__init__.py
@@ -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(

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to