I'm trying to patch a config file used in a django app and having trouble understanding how to do it given the way we import the config. I don't think the fact that it's Django has much relevance here, but it partially drives this file structure.
app/views.py
from . import config as APP_CONFIG
...later on in some function...
retry_count = APP_CONFIG.MAX_NUMBER_RETRIES
app/config.py
MAX_NUMBER_RETRIES = 1
How do I properly patch this config setting?
I've tried varieties of @patch('app.views.CONFIG.MAX_NUMBER_RETRIES', 1)
or @patch('app.config.MAX_NUMBER_RETRIES', 1)
in my testing function to no avail (I use pytest).
Aucun commentaire:
Enregistrer un commentaire