Issue
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?
Solution
I guess, settings()
and override_settings()
can effectively used as context but, the documentation says settings()
has to be used as context, and override_settings()
has 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.
Answered By - Lucas Grugru
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.