コード例 #1
0
    def test_can_load_classes_with_list(self):
        from politicos.models.political_party import PoliticalParty

        classes = load_classes(default=[
            ['politicos.models.political_party.PoliticalParty'],
        ])

        expect(classes).to_length(1)
        expect(classes[0]).to_equal(PoliticalParty)
コード例 #2
0
    def test_cannot_load_classes_attr_error(self, get_class_mock, log_mock):
        get_class_mock.side_effect = AttributeError
        classes = load_classes(default=['blah.models.blah.Test'])

        expect(classes).to_length(0)
        expect(log_mock.mock_calls).to_include(
            call.warn(
                'Class [%s] not found. Will be ignored.',
                'blah.models.blah.Test'
            )
        )
コード例 #3
0
    def test_cannot_load_classes_value_error(self, get_class_mock, log_mock):
        get_class_mock.side_effect = ValueError
        classes = load_classes(default=['blah.models.blah.Test'])

        expect(classes).to_length(0)
        expect(log_mock.mock_calls).to_include(
            call.warn(
                'Invalid class name [%s]. Will be ignored.',
                'blah.models.blah.Test'
            )
        )
コード例 #4
0
ファイル: server.py プロジェクト: scorphus/politicos
 def _load_error_handlers(self):
     return load_classes(default=self.config.ERROR_HANDLERS)