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

This commit is contained in:
Tom Christie 2015-07-02 10:28:46 +01:00
parent a03b89f326
commit fb4233736f
2 changed files with 14 additions and 1 deletions

View File

@ -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

View File

@ -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))