Skip to content

Commit e8da759

Browse files
committed
improve test
1 parent c80120e commit e8da759

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

Lib/test/test_import/__init__.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -814,15 +814,12 @@ def test_frozen_module_from_import_error(self):
814814
f"cannot import name 'this_will_never_exist' from 'os' ({os.__file__})",
815815
str(cm.exception),
816816
)
817-
818-
expected_error = (
819-
b"cannot import name 'this_will_never_exist' "
820-
b"from 'sys' (unknown location)"
817+
with self.assertRaises(ImportError) as cm:
818+
from sys import this_will_never_exist
819+
self.assertIn(
820+
"cannot import name 'this_will_never_exist' from 'sys' (unknown location)",
821+
str(cm.exception),
821822
)
822-
popen = script_helper.spawn_python("-c", "from sys import this_will_never_exist")
823-
stdout, stderr = popen.communicate()
824-
self.assertIn(expected_error, stdout)
825-
826823

827824
scripts = [
828825
"""

0 commit comments

Comments
 (0)