mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #28026: Raise ImportError when exec_module() exists but create_module() is missing.
This commit is contained in:
parent
e58571b7ea
commit
f3fd06a2e4
4 changed files with 902 additions and 910 deletions
|
@ -47,14 +47,8 @@ class ModuleFromSpecTests:
|
|||
def exec_module(self, module):
|
||||
pass
|
||||
spec = self.machinery.ModuleSpec('test', Loader())
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
warnings.simplefilter('always')
|
||||
with self.assertRaises(ImportError):
|
||||
module = self.util.module_from_spec(spec)
|
||||
self.assertEqual(1, len(w))
|
||||
self.assertTrue(issubclass(w[0].category, DeprecationWarning))
|
||||
self.assertIn('create_module', str(w[0].message))
|
||||
self.assertIsInstance(module, types.ModuleType)
|
||||
self.assertEqual(module.__name__, spec.name)
|
||||
|
||||
def test_create_module_returns_None(self):
|
||||
class Loader(self.abc.Loader):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue