summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2024-10-25 07:18:45 (GMT)
committerGitHub <noreply@github.com>2024-10-25 07:18:45 (GMT)
commit75401febc91a449cc4f4391d663e9a96ce91bb6c (patch)
tree2eb7149df4fe320f7f34ad71d5e006be7668f48c /Lib
parent2513593303b306cd8273682811d26600651c60e4 (diff)
downloadcpython-75401febc91a449cc4f4391d663e9a96ce91bb6c.zip
cpython-75401febc91a449cc4f4391d663e9a96ce91bb6c.tar.gz
cpython-75401febc91a449cc4f4391d663e9a96ce91bb6c.tar.bz2
gh-123930: Correct test of attribute failure to account for iOS (#125959)
Update a test of importing attributes from binary modules to account for iOS conditions.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_import/__init__.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/test/test_import/__init__.py b/Lib/test/test_import/__init__.py
index 5b7ba90..e6fd33e 100644
--- a/Lib/test/test_import/__init__.py
+++ b/Lib/test/test_import/__init__.py
@@ -370,10 +370,14 @@ class ImportTests(unittest.TestCase):
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(