Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7e0a181

Browse files
committed
Make test_import more robust and stop using assertRaisesRegexp().
1 parent a93c6db commit 7e0a181

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

Lib/test/test_import.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,11 +322,11 @@ def test_delete_builtins_import(self):
322322
self.assertIn(b"ImportError", stdout)
323323

324324
def test_from_import_message_for_nonexistent_module(self):
325-
with self.assertRaisesRegexp(ImportError, "^No module named 'bogus'"):
325+
with self.assertRaisesRegex(ImportError, "^No module named 'bogus'"):
326326
from bogus import foo
327327

328328
def test_from_import_message_for_existing_module(self):
329-
with self.assertRaisesRegexp(ImportError, "^cannot import name 'bogus'"):
329+
with self.assertRaisesRegex(ImportError, "^cannot import name 'bogus'"):
330330
from re import bogus
331331

332332

@@ -689,6 +689,7 @@ def test_missing_source(self):
689689
self.assertTrue(os.path.exists(pyc_file))
690690
os.remove(self.source)
691691
forget(TESTFN)
692+
importlib.invalidate_caches()
692693
self.assertRaises(ImportError, __import__, TESTFN)
693694

694695
@skip_if_dont_write_bytecode

0 commit comments

Comments
 (0)