Esempio n. 1
0
 def get_factory(self):
     """Retrieve the wrapped factory.Factory subclass."""
     if self.factory is None:
         # Must be a module path
         self.factory = utils.import_object(self.factory_module,
                                            self.factory_name)
     return self.factory
    def get_factory(self):
        """Retrieve the factory.Factory subclass.

        Its value is cached in the 'factory' attribute, and retrieved through
        the factory_getter callable.
        """
        if self.factory is None:
            factory_class = utils.import_object(
                self.module_name, self.factory_name)

            self.factory = factory_class
        return self.factory
    def get_factory(self):
        """Retrieve the factory.Factory subclass.

        Its value is cached in the 'factory' attribute, and retrieved through
        the factory_getter callable.
        """
        if self.factory is None:
            factory_class = utils.import_object(self.module_name,
                                                self.factory_name)

            self.factory = factory_class
        return self.factory
Esempio n. 4
0
 def test_datetime(self):
     imported = utils.import_object('datetime', 'date')
     import datetime
     d = datetime.date
     self.assertEqual(d, imported)
Esempio n. 5
0
 def test_datetime(self):
     imported = utils.import_object('datetime', 'date')
     import datetime
     d = datetime.date
     self.assertEqual(d, imported)
Esempio n. 6
0
 def get_factory(self):
     """Retrieve the wrapped factory.Factory subclass."""
     if self.factory is None:
         # Must be a module path
         self.factory = utils.import_object(self.factory_module, self.factory_name)
     return self.factory
Esempio n. 7
0
 def test_invalid_module(self):
     with self.assertRaises(ImportError):
         utils.import_object('this-is-an-invalid-module', '__name__')
Esempio n. 8
0
 def test_unknown_attribute(self):
     with self.assertRaises(AttributeError):
         utils.import_object('datetime', 'foo')