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
Asked
Active
Viewed 62 times
1 Answers
2
from ... import config
config.balance_check = False
This is called monkey patch
-
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. – user2968440 Feb 24 '14 at 11:58
-
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? – iskorum Feb 24 '14 at 12:17