def _get_factory(cls): if getattr(cls, 'FACTORY_CLASS', None): factory_cls = getattr(cls, 'FACTORY_CLASS', None) if isinstance(factory_cls, string_types): factory_cls = import_string(factory_cls) create_cls = factory_cls.create else: create_cls = cls.create return create_cls
def test_imports_correctly(self): cp = import_string('mogwai.tools:cached_property') self.assertIs(cp, cached_property)
def test_raises_import_string_error(self): with self.assertRaises(ImportStringError): import_string('does.not.exist') with self.assertRaises(ImportStringError): import_string('does.not:exist')