diff options
Diffstat (limited to 'Lib/test')
| -rw-r--r-- | Lib/test/test_import.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py index e6a43792ee..61df86a841 100644 --- a/Lib/test/test_import.py +++ b/Lib/test/test_import.py @@ -321,6 +321,14 @@ class ImportTests(unittest.TestCase): stdout, stderr = popen.communicate() self.assertIn(b"ImportError", stdout) + def test_from_import_message_for_nonexistent_module(self): + with self.assertRaisesRegexp(ImportError, "^No module named 'bogus'"): + from bogus import foo + + def test_from_import_message_for_existing_module(self): + with self.assertRaisesRegexp(ImportError, "^cannot import name 'bogus'"): + from re import bogus + @skip_if_dont_write_bytecode class FilePermissionTests(unittest.TestCase): |
