Пример #1
0
    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
Пример #2
0
 def test_imports_correctly(self):
     cp = import_string('mogwai.tools:cached_property')
     self.assertIs(cp, cached_property)
Пример #3
0
 def test_imports_correctly(self):
     cp = import_string('mogwai.tools:cached_property')
     self.assertIs(cp, cached_property)
Пример #4
0
 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')
Пример #5
0
 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')