Esempio n. 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
Esempio n. 2
0
 def test_imports_correctly(self):
     cp = import_string('mogwai.tools:cached_property')
     self.assertIs(cp, cached_property)
Esempio n. 3
0
 def test_imports_correctly(self):
     cp = import_string('mogwai.tools:cached_property')
     self.assertIs(cp, cached_property)
Esempio n. 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')
Esempio n. 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')