mercredi 12 février 2020

How to override app_settings while testing

Okay now, I have

settings.py

SETTING1='value'
SETTING2='value'

After that we realized that these settings SETTING1 and SETTING2 are more specified to app1 So we've added them apps.py

from django.apps import AppConfig


class EXAPPConfig(AppConfig):
    name = 'EXAPPConfig'
    verbose_name = "EXAPPConfig"
    SETTING1 = 'value'
    def ready(self):
        pass

and call them withviews.py

app_settings = apps.get_app_config('ex_app')
app_settings.SETTING1

according to Django documentation

So how can I override them with override_settings at tests @override_settings I tried @patch to patch the config app but failed

Aucun commentaire:

Enregistrer un commentaire