mock or override values in apps.py (Django) for testing

Viewed 57

Typically I'd set a value in settings.py and then use @override_settings in tests to override it.

Is there any similar mechanism that exists for overriding settings in apps.py when using app_config?

For instance

# apps.py
class MyConfig(AppConfig):
    SOME_VAR = "SOME_VAR"

# some .py file
from django.apps import apps
apps.get_app_config('some_app').SOME_VAR

# some test.py
# How to change the value that apps.get_app_config('some_app').SOME_VAR returns?

It's strange this isn't covered in the docs as it feels this would be a common use case or maybe I'm missing something?

Thanks,

0 Answers
Related