Brett Cannon avatar Brett Cannon committed 0bceedc

Make test_import more robust and stop using assertRaisesRegexp().

Comments (0)

Files changed (1)


         self.assertIn(b"ImportError", stdout)
     def test_from_import_message_for_nonexistent_module(self):
-        with self.assertRaisesRegexp(ImportError, "^No module named 'bogus'"):
+        with self.assertRaisesRegex(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'"):
+        with self.assertRaisesRegex(ImportError, "^cannot import name 'bogus'"):
             from re import bogus
+        importlib.invalidate_caches()
         self.assertRaises(ImportError, __import__, TESTFN)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.