def test_unloadable(self):
    loader = self.machinery.SourceFileLoader('good name', {})
    module = types.ModuleType('bad name')
    module.__spec__ = self.machinery.ModuleSpec('bad name', loader)
    with self.assertRaises(ImportError):
        loader.exec_module(module)
    with self.assertRaises(ImportError):
        with warnings.catch_warnings():
            warnings.simplefilter('ignore', DeprecationWarning)
            loader.load_module('bad name')
def test_unloadable(self):
    loader = self.machinery.SourceFileLoader('good name', {})
    module = types.ModuleType('bad name')
    module.__spec__ = self.machinery.ModuleSpec('bad name', loader)
    with self.assertRaises(ImportError):
        loader.exec_module(module)
    with self.assertRaises(ImportError):
        with warnings.catch_warnings():
            warnings.simplefilter('ignore', DeprecationWarning)
            loader.load_module('bad name')