I have a file config.py and there is a variable in it balance_check which is true by default. I have one more alltests.py which takes certain parameters and executes other files. I want to set the value of balance_check variable to false when i am passing some particular parameter to alltests file but some how the variable does not changes for sub sequent files called from alltests.py file
1 Answer
from ... import config
config.balance_check = False
This is called monkey patch
2 Comments
user2968440
I tried this but when alltests.py is calling other python file it seems that the scope of balance_check var ends and the value is picked from config.py file directly which is True.
iskorum
you execute
alltests file, it sets balance_check variable to False in config file, then call another file and in that file you use balance_check variable from config file but it is still True, am i right?