          self.assertFalse(module_has_submodule(sys.modules['utils_tests'], 'types'))
  
          # A module which doesn't have a __path__ (so no submodules)
          self.assertFalse(module_has_submodule(test_no_submodule, 'anything'))
          self.assertRaises(ImportError, import_module,
              'utils_tests.test_no_submodule.anything')
  
  
  class EggLoader(unittest.TestCase):
      def setUp(self):
          self.egg_dir = '%s/eggs' % os.path.dirname(upath(__file__))
 
</s> remove             self.assertRaises(ImportError, import_module, 'egg_module.no_such_module')
 </s> add             with self.assertRaises(ImportError):
                import_module('egg_module.no_such_module') </s> remove         self.assertRaises(ImportError, import_module, 'utils_tests.test_module.django')
 </s> add         with self.assertRaises(ImportError):
            import_module('utils_tests.test_module.django') </s> remove             self.assertRaises(ImportError, import_module, 'egg_module.sub1.sub2.no_such_module')
 </s> add             with self.assertRaises(ImportError):
                import_module('egg_module.sub1.sub2.no_such_module') </s> remove         self.assertRaises(ImportError, import_module, 'utils_tests.test_module.no_such_module')
 </s> add         with self.assertRaises(ImportError):
            import_module('utils_tests.test_module.no_such_module') </s> remove             self.assertRaises(ImportError, import_module, 'egg_module.bad_module')
 </s> add             with self.assertRaises(ImportError):
                import_module('egg_module.bad_module')
        with self.assertRaises(ImportError):
            import_module('utils_tests.test_no_submodule.anything')
          self.assertFalse(module_has_submodule(sys.modules['utils_tests'], 'types'))
  
          # A module which doesn't have a __path__ (so no submodules)
          self.assertFalse(module_has_submodule(test_no_submodule, 'anything'))
        with self.assertRaises(ImportError):
            import_module('utils_tests.test_no_submodule.anything')
        with self.assertRaises(ImportError):
            import_module('utils_tests.test_no_submodule.anything')
  
  
  class EggLoader(unittest.TestCase):
      def setUp(self):
          self.egg_dir = '%s/eggs' % os.path.dirname(upath(__file__))
keep keep keep keep replace replace keep keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/utils_tests/test_module_loading.py