Here are the examples of the python api django.test.utils.override_settings taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
52 Examples
3
View Complete Implementation : testcases.py
Copyright GNU General Public License v2.0
Author : blackye
Copyright GNU General Public License v2.0
Author : blackye
def settings(self, **kwargs):
"""
A context manager that temporarily sets a setting and reverts
back to the original value when exiting the context.
"""
return override_settings(**kwargs)
3
View Complete Implementation : test_admin_provider.py
Copyright MIT License
Author : chessbr
Copyright MIT License
Author : chessbr
def test_admin_scope_permission_provider():
with override_settings(
REST_JWT_PERMISSION={
"SCOPE_PROVIDERS": [
"rest_jwt_permission.providers.AdminScopeProvider"
]
}
):
scopes = get_all_permission_providers_scopes()
expected_identifiers = [
'superuser'
]
scope_ids = [s.identifier for s in scopes]
astert len(scope_ids) == len(expected_identifiers)
astert set(scope_ids) == set(expected_identifiers)
astert all([isinstance(s, Scope) for s in scopes])
astert all([isinstance(s, SimpleScope) for s in scopes])
astert not any([isinstance(s, APIScope) for s in scopes])
3
View Complete Implementation : tests.py
Copyright Apache License 2.0
Author : chris104957
Copyright Apache License 2.0
Author : chris104957
@mock.patch('carrot.consumer.Consumer', new_callable=mock_consumer)
@mock.patch('pika.BlockingConnection', new_callable=mock_connection)
def test_consumer_set(self, *args):
alt_settings = {
'queues': [{
'name': 'test',
'durable': True,
'queue_arguments': {'blah': True},
'exchange_arguments': {'blah': True},
}]
}
with override_settings(CARROT=alt_settings):
cs = ConsumerSet(VirtualHost('amqp://guest:guest@localhost:5672/test'), 'test', logger)
cs.start_consuming()
cs.stop_consuming()
3
View Complete Implementation : tests.py
Copyright BSD 2-Clause "Simplified" License
Author : django-otp
Copyright BSD 2-Clause "Simplified" License
Author : django-otp
def test_config_url_no_issuer(self):
with override_settings(OTP_HOTP_ISSUER=None):
url = self.device.config_url
parsed = urlsplit(url)
params = parse_qs(parsed.query)
self.astertEqual(parsed.scheme, 'otpauth')
self.astertEqual(parsed.netloc, 'hotp')
self.astertEqual(parsed.path, '/alice')
self.astertIn('secret', params)
self.astertNotIn('issuer', params)
3
View Complete Implementation : tests.py
Copyright BSD 2-Clause "Simplified" License
Author : django-otp
Copyright BSD 2-Clause "Simplified" License
Author : django-otp
def test_config_url_issuer(self):
with override_settings(OTP_HOTP_ISSUER='example.com'):
url = self.device.config_url
parsed = urlsplit(url)
params = parse_qs(parsed.query)
self.astertEqual(parsed.scheme, 'otpauth')
self.astertEqual(parsed.netloc, 'hotp')
self.astertEqual(parsed.path, '/example.com%3Aalice')
self.astertIn('secret', params)
self.astertIn('issuer', params)
self.astertEqual(params['issuer'][0], 'example.com')
3
View Complete Implementation : tests.py
Copyright BSD 2-Clause "Simplified" License
Author : django-otp
Copyright BSD 2-Clause "Simplified" License
Author : django-otp
def test_config_url_issuer_spaces(self):
with override_settings(OTP_HOTP_ISSUER='Very Trustworthy Source'):
url = self.device.config_url
parsed = urlsplit(url)
params = parse_qs(parsed.query)
self.astertEqual(parsed.scheme, 'otpauth')
self.astertEqual(parsed.netloc, 'hotp')
self.astertEqual(parsed.path, '/Very%20Trustworthy%20Source%3Aalice')
self.astertIn('secret', params)
self.astertIn('issuer', params)
self.astertEqual(params['issuer'][0], 'Very Trustworthy Source')
3
View Complete Implementation : tests.py
Copyright BSD 2-Clause "Simplified" License
Author : django-otp
Copyright BSD 2-Clause "Simplified" License
Author : django-otp
def test_config_url(self):
with override_settings(OTP_TOTP_ISSUER=None):
url = self.device.config_url
parsed = urlsplit(url)
params = parse_qs(parsed.query)
self.astertEqual(parsed.scheme, 'otpauth')
self.astertEqual(parsed.netloc, 'totp')
self.astertEqual(parsed.path, '/alice')
self.astertIn('secret', params)
self.astertNotIn('issuer', params)
3
View Complete Implementation : tests.py
Copyright BSD 2-Clause "Simplified" License
Author : django-otp
Copyright BSD 2-Clause "Simplified" License
Author : django-otp
def test_config_url_issuer(self):
with override_settings(OTP_TOTP_ISSUER='example.com'):
url = self.device.config_url
parsed = urlsplit(url)
params = parse_qs(parsed.query)
self.astertEqual(parsed.scheme, 'otpauth')
self.astertEqual(parsed.netloc, 'totp')
self.astertEqual(parsed.path, '/example.com%3Aalice')
self.astertIn('secret', params)
self.astertIn('issuer', params)
self.astertEqual(params['issuer'][0], 'example.com')
3
View Complete Implementation : tests.py
Copyright BSD 2-Clause "Simplified" License
Author : django-otp
Copyright BSD 2-Clause "Simplified" License
Author : django-otp
def test_config_url_issuer_spaces(self):
with override_settings(OTP_TOTP_ISSUER='Very Trustworthy Source'):
url = self.device.config_url
parsed = urlsplit(url)
params = parse_qs(parsed.query)
self.astertEqual(parsed.scheme, 'otpauth')
self.astertEqual(parsed.netloc, 'totp')
self.astertEqual(parsed.path, '/Very%20Trustworthy%20Source%3Aalice')
self.astertIn('secret', params)
self.astertIn('issuer', params)
self.astertEqual(params['issuer'][0], 'Very Trustworthy Source')
3
View Complete Implementation : tests.py
Copyright Apache License 2.0
Author : edisonlz
Copyright Apache License 2.0
Author : edisonlz
@skipIf(settings.TIME_ZONE != "America/Chicago" and pytz is None,
"this test requires pytz when a non-default time zone is set")
def test_naturalday_uses_localtime(self):
# Regression for #18504
# This is 2012-03-08HT19:30:00-06:00 in America/Chicago
dt = datetime.datetime(2012, 3, 9, 1, 30, tzinfo=utc)
orig_humanize_datetime, humanize.datetime = humanize.datetime, MockDateTime
try:
with override_settings(TIME_ZONE="America/Chicago", USE_TZ=True):
with translation.override('en'):
self.humanize_tester([dt], ['yesterday'], 'naturalday')
finally:
humanize.datetime = orig_humanize_datetime