Beispiel #1
0
    def get_light_storage(self, backend: str,
                          options: Dict[str, Any]) -> LightStorage:
        """
        Create a light storage instance.

        :param backend: A fully qualified name of the backend class.
        :param options: The options to pass to the backend.
        :return: A light storage instance.
        """
        return import_from_module(backend)(**options)
def get_auxiliary_storage(backend: str,
                          options: Dict[str, Any]) -> AuxiliaryStorage:
    """
    Create an auxiliary storage instance.

    :param backend: A fully qualified name of the backend class.
    :param options: The options to pass to the backend.
    :return: An auxiliary storage instance.
    """
    return import_from_module(backend)(**options)
Beispiel #3
0
 def test_import_from_module_invalid_name(self):
     with self.assertRaisesMessage(
             ValueError, "Invalid fully qualified name: 'OnlyClassName'."):
         import_from_module('OnlyClassName')
Beispiel #4
0
 def test_import_from_module_member_not_found(self):
     with self.assertRaisesMessage(
             ImportError,
             'ThisClassDoesNotExist not found in http.server.'):
         import_from_module('http.server.ThisClassDoesNotExist')
Beispiel #5
0
 def test_import_from_module(self):
     result = import_from_module('http.server.HTTPServer')
     from http.server import HTTPServer
     self.assertIs(result, HTTPServer)