What is the difference between SimpleTestCase.settings() and django.test.override_settings?

Django provides different ways to change settings(documentations) in a test in different levels (TestCase class, test method, context manager). I understand the difference between override_settings and modify_settings, but I can't get the difference between SimpleTestCase.settings() and django.test.override_settings() when being used as a context manager. Is there any difference in functionality or preference in which one to use?

I guess, settings() and override_settings() can effectively used as context but, the documentation says settings() have to be used as context, and override_settings() have to be used as decorator.

But, it is quite possible that in the future, the decorator can only be used as a decorator. It is best to follow the documentation and not attempt to misuse the tools provided by Django. Django developers may have made this change to allow a transition from previous usage and the behavior is the same only for a few versions.

Back to Top