def test_get_class_no_such_class(self): with self.assertRaises(AttributeError): factory.get_class(str(self.__module__) + ".NoSuchClass")
def test_get_class_no_prefix(self): with self.assertRaises(ValueError): factory.get_class("Counter")
def test_get_class_no_such_module(self): with self.assertRaises(ImportError): factory.get_class("nosuchmodule.NoSuchClass")
def test_get_class(self): my_module = self.__module__ clazz = factory.get_class(str(self.__module__) + ".Counter") self.assertEqual(Counter, clazz)