def test_invalid_modulename(self): with self.assertRaises(ImproperlyConfigured): load_class_from_path("allmodulenoklass") with self.assertRaises(ImproperlyConfigured): load_class_from_path("badmodule.badclass") with self.assertRaises(ImproperlyConfigured): load_class_from_path("tests.blah") with self.assertRaises(ImproperlyConfigured): load_class_from_path("tests.BADClass")
def _load_zone(zone_name, **config): vary_klass = load_class_from_path(config['VARY']) return ThrottleZone(zone_name, vary_klass, **config)
def load_backend_from_path(classpath): klass = load_class_from_path(classpath) try: return klass() except TypeError: raise ImproperlyConfigured("%s is not callable" % (klass.__name__))
def test_get_module(self): module = load_class_from_path("throttle.tests.backends.TestThrottleBackend") self.assertEqual(module.__name__, 'TestThrottleBackend')
def test_get_module(self): module = load_class_from_path( "throttle.tests.backends.TestThrottleBackend") self.assertEqual(module.__name__, 'TestThrottleBackend')