Q: overriding settings
See original GitHub issueIs there a recommended way to override settings for the live server? Normally I’d use @override_settings(DEBUG=True)
so I can see tracebacks while debugging, but had to settle for this:
def before_scenario(context, scenario):
if "DEBUG" in scenario.tags:
from django.conf import settings
settings.DEBUG = True
(and corresponding after_scenario())
It works, but is there a better way?
Issue Analytics
- State:
- Created 7 years ago
- Comments:18 (6 by maintainers)
Top Results From Across the Web
How To Override Default Statistical Testing Settings
By default, Q automatically takes into account the structure of the data when determining how to perform tests.
Read more >Overriding Chrome settings in Chrome Extensions
Settings overrides are a way for extensions to override selected Chrome settings. The API is available on Windows in all current versions of ......
Read more >how to auto override force dark mode in android Q | XDA Forums
First, turn off regular dark mode (if enabled) and reboot your cell phone. Then, toggle the override-dark-mode option in developer settings and ...
Read more >Overriding settings in Django when used by the models
Finally, avoid aliasing your settings as module-level constants as override_settings() won't work on such values since they are only evaluated the first time ......
Read more >How to Statically Override the Default Settings in jOOQ
… and much more. Your configuration will probably include an explicit Settings instance where you have fine grained, perhaps even per-execution ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@farcepest are you still alive?
It makes sense to me for settings to work similar to how behave-django allows fixture loading, where behave-django would support both of the following options:
Interface:
Option 1: in
before_scenario
In this example, we override settings for a particular scenario. Since a new test class is instantiated for each scenario, teardown is automatic:
Option 2: via decorator on step functions
In this example, we define a Given Step that uses the
behave_django.decorators.override_settings
decorator, which behave-django would use to override django’s settings for the entire scenario:Implementation:
I’m assuming that in the code where behave-django adds fixtures to the TestCase class, the django settings can also be overwritten. This can possibly be done with django.test.utils.override_settings, either using the class as a context, or mimicking what the
decorate_class
method is doing. Thoughts?