0

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 Answers1

2
from ... import config

config.balance_check = False

This is called monkey patch

Community
  • 1
  • 1
iskorum
  • 1,137
  • 1
  • 16
  • 27
  • 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