Esempio n. 1
0
    def test_getting_class(self):
        cls = get_class('django.test.TestCase')
        cls2 = get_class('thisisnotaclass')
        cls3 = get_class('thisisnotaclass.alsothis')

        self.assertEqual(cls, TestCase)
        self.assertEqual(cls2, None)
        self.assertEqual(cls3, None)
Esempio n. 2
0
    def get_processor(self, processor_defn):
        class_path, init_kwargs = None, {}
        if isinstance(processor_defn, basestring):
            class_path = processor_defn
        elif isinstance(processor_defn, (list, tuple)):
            if len(processor_defn) == 1:
                class_path = processor_defn[0]
            elif len(processor_defn) == 2:
                class_path, init_kwargs = processor_defn

        if class_path:
            processor_class = get_class(class_path)

            if processor_class:
                return processor_class(**init_kwargs)

        raise ImproperlyConfigured("Invalid processor: %s" % repr(processor_defn))
Esempio n. 3
0
    def get_processor(self, processor_defn):
        class_path, init_kwargs = None, {}
        if isinstance(processor_defn, basestring):
            class_path = processor_defn
        elif isinstance(processor_defn, (list, tuple)):
            if len(processor_defn) == 1:
                class_path = processor_defn[0]
            elif len(processor_defn) == 2:
                class_path, init_kwargs = processor_defn

        if class_path:
            processor_class = get_class(class_path)

            if processor_class:
                return processor_class(**init_kwargs)

        raise ImproperlyConfigured("Invalid processor: %s" %
                                   repr(processor_defn))