Commit fb423373 by Tom Christie

Empty settings should also be coerced to lists. Closes #3087.

parent a03b89f3
...@@ -204,7 +204,7 @@ class APISettings(object): ...@@ -204,7 +204,7 @@ class APISettings(object):
val = self.defaults[attr] val = self.defaults[attr]
# Coerce import strings into classes # Coerce import strings into classes
if val and attr in self.import_strings: if attr in self.import_strings:
val = perform_import(val, attr) val = perform_import(val, attr)
# Cache the result # Cache the result
......
...@@ -17,3 +17,16 @@ class TestSettings(TestCase): ...@@ -17,3 +17,16 @@ class TestSettings(TestCase):
}) })
with self.assertRaises(ImportError): with self.assertRaises(ImportError):
settings.DEFAULT_RENDERER_CLASSES 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))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment