mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-02 20:54:42 +03:00
Empty settings should also be coerced to lists. Closes #3087.
This commit is contained in:
parent
a03b89f326
commit
fb4233736f
|
@ -204,7 +204,7 @@ class APISettings(object):
|
|||
val = self.defaults[attr]
|
||||
|
||||
# Coerce import strings into classes
|
||||
if val and attr in self.import_strings:
|
||||
if attr in self.import_strings:
|
||||
val = perform_import(val, attr)
|
||||
|
||||
# Cache the result
|
||||
|
|
|
@ -17,3 +17,16 @@ class TestSettings(TestCase):
|
|||
})
|
||||
with self.assertRaises(ImportError):
|
||||
settings.DEFAULT_RENDERER_CLASSES
|
||||
|
||||
|
||||
class TestSettingTypes(TestCase):
|
||||
def test_settings_consistently_coerced_to_list(self):
|
||||
settings = APISettings({
|
||||
'DEFAULT_THROTTLE_CLASSES': ('rest_framework.throttling.BaseThrottle',)
|
||||
})
|
||||
self.assertTrue(isinstance(settings.DEFAULT_THROTTLE_CLASSES, list))
|
||||
|
||||
settings = APISettings({
|
||||
'DEFAULT_THROTTLE_CLASSES': ()
|
||||
})
|
||||
self.assertTrue(isinstance(settings.DEFAULT_THROTTLE_CLASSES, list))
|
||||
|
|
Loading…
Reference in New Issue
Block a user