Python django.test.modify_settings() Examples

The following are 7 code examples for showing how to use django.test.modify_settings(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module django.test , or try the search function .

Example 1
Project: django_coverage_plugin   Author: nedbat   File: test_engines.py    License: Apache License 2.0 6 votes vote down vote up
def setUp(self):
        super(MultipleEngineTests, self).setUp()

        engine = {
            'NAME': 'other',
            'BACKEND': 'django.template.backends.django.DjangoTemplates',
            'DIRS': ['templates2'],         # where the tests put things.
            'OPTIONS': {
                'debug': True,
            },
        }
        modified_settings = modify_settings(TEMPLATES={'append': [engine]})
        modified_settings.enable()
        self.addCleanup(modified_settings.disable)

        self.template_directory = 'templates2' 
Example 2
Project: Kiwi   Author: kiwitcms   File: views.py    License: GNU General Public License v2.0 6 votes vote down vote up
def render_to_response(self, context, **response_kwargs):
        self.response_class.modify_settings = modify_settings(
            MENU_ITEMS={'append': [
                ('...', [
                    (
                        _('Edit'),
                        reverse('testcases-edit', args=[self.object.pk])
                    ),
                    (
                        _('Clone'),
                        reverse('testcases-clone') + "?case=%d" % self.object.pk
                    ),
                    (
                        _('History'),
                        "/admin/testcases/testcase/%d/history/" % self.object.pk
                    ),
                    ('-', '-'),
                    (
                        _('Delete'),
                        reverse('admin:testcases_testcase_delete', args=[self.object.pk])
                    )])]}
        )
        return super().render_to_response(context, **response_kwargs) 
Example 3
Project: Kiwi   Author: kiwitcms   File: views.py    License: GNU General Public License v2.0 6 votes vote down vote up
def render_to_response(self, context, **response_kwargs):
        self.response_class.modify_settings = modify_settings(
            MENU_ITEMS={'append': [
                ('...', [
                    (
                        _('Edit'),
                        reverse('bugs-edit', args=[self.object.pk])
                    ),
                    ('-', '-'),
                    (
                        _('Delete'),
                        reverse('admin:bugs_bug_delete', args=[self.object.pk])
                    ),
                ])
            ]}
        )
        return super().render_to_response(context, **response_kwargs) 
Example 4
Project: django_coverage_plugin   Author: nedbat   File: test_engines.py    License: Apache License 2.0 5 votes vote down vote up
def test_third_engine_not_debug(self):
        engine3 = {
            'NAME': 'notdebug',
            'BACKEND': 'django.template.backends.django.DjangoTemplates',
            'DIRS': ['templates3'],         # where the tests put things.
        }
        modified_settings = modify_settings(TEMPLATES={'append': [engine3]})
        modified_settings.enable()
        self.addCleanup(modified_settings.disable)

        self.make_template('Hello')
        with self.assert_plugin_disabled("Template debugging must be enabled in settings."):
            self.run_django_coverage() 
Example 5
Project: djongo   Author: nesdis   File: test_remote_user.py    License: GNU Affero General Public License v3.0 5 votes vote down vote up
def setUp(self):
        self.patched_settings = modify_settings(
            AUTHENTICATION_BACKENDS={'append': self.backend},
            MIDDLEWARE={'append': self.middleware},
        )
        self.patched_settings.enable() 
Example 6
def setUp(self):
        self.patched_settings = modify_settings(
            AUTHENTICATION_BACKENDS={'append': self.backend},
            MIDDLEWARE={'append': self.middleware},
        )
        self.patched_settings.enable() 
Example 7
Project: djongo   Author: nesdis   File: test_remote_user.py    License: GNU Affero General Public License v3.0 5 votes vote down vote up
def setUp(self):
        self.patched_settings = modify_settings(
            AUTHENTICATION_BACKENDS={'append': self.backend},
            MIDDLEWARE={'append': self.middleware},
        )
        self.patched_settings.enable()