Skip to content
Merged
Changes from 1 commit
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