From 8a33284d191025bc387644666807311eb7d60384 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Fri, 8 Jul 2016 11:00:00 -0700 Subject: Issue #26896: Disambiguate uses of "importer" with "finder". Thanks to Oren Milman for the patch. --- Lib/test/test_importlib/import_/test_meta_path.py | 1 - 1 file changed, 1 deletion(-) (limited to 'Lib/test/test_importlib/import_') diff --git a/Lib/test/test_importlib/import_/test_meta_path.py b/Lib/test/test_importlib/import_/test_meta_path.py index c452cdd063..5a41e8968a 100644 --- a/Lib/test/test_importlib/import_/test_meta_path.py +++ b/Lib/test/test_importlib/import_/test_meta_path.py @@ -76,7 +76,6 @@ class CallSignature: self.__import__(mod_name) assert len(log) == 1 args = log[0][0] - kwargs = log[0][1] # Assuming all arguments are positional. self.assertEqual(args[0], mod_name) self.assertIsNone(args[1]) -- cgit v1.2.1 From 54dc09e399e40109e5b61f0ed2e94558cc07aaa8 Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Wed, 7 Sep 2016 16:56:15 -0700 Subject: Issue #15767: Use ModuleNotFoundError. --- Lib/test/test_importlib/import_/test_api.py | 4 ++++ Lib/test/test_importlib/import_/test_fromlist.py | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'Lib/test/test_importlib/import_') diff --git a/Lib/test/test_importlib/import_/test_api.py b/Lib/test/test_importlib/import_/test_api.py index 7069d9e58d..a7bf2749cf 100644 --- a/Lib/test/test_importlib/import_/test_api.py +++ b/Lib/test/test_importlib/import_/test_api.py @@ -43,6 +43,10 @@ class APITest: """Test API-specific details for __import__ (e.g. raising the right exception when passing in an int for the module name).""" + def test_raises_ModuleNotFoundError(self): + with self.assertRaises(ModuleNotFoundError): + util.import_importlib('some module that does not exist') + def test_name_requires_rparition(self): # Raise TypeError if a non-string is passed in for the module name. with self.assertRaises(TypeError): diff --git a/Lib/test/test_importlib/import_/test_fromlist.py b/Lib/test/test_importlib/import_/test_fromlist.py index 80454655ad..14640032b4 100644 --- a/Lib/test/test_importlib/import_/test_fromlist.py +++ b/Lib/test/test_importlib/import_/test_fromlist.py @@ -73,16 +73,16 @@ class HandlingFromlist: self.assertTrue(hasattr(module, 'module')) self.assertEqual(module.module.__name__, 'pkg.module') - def test_module_from_package_triggers_ImportError(self): - # If a submodule causes an ImportError because it tries to import - # a module which doesn't exist, that should let the ImportError - # propagate. + def test_module_from_package_triggers_ModuleNotFoundError(self): + # If a submodule causes an ModuleNotFoundError because it tries + # to import a module which doesn't exist, that should let the + # ModuleNotFoundError propagate. def module_code(): import i_do_not_exist with util.mock_modules('pkg.__init__', 'pkg.mod', module_code={'pkg.mod': module_code}) as importer: with util.import_state(meta_path=[importer]): - with self.assertRaises(ImportError) as exc: + with self.assertRaises(ModuleNotFoundError) as exc: self.__import__('pkg', fromlist=['mod']) self.assertEqual('i_do_not_exist', exc.exception.name) -- cgit v1.2.1