title: pytest: How to set global variable values in pytest test function
body: <p>app.py below, running env = python 3.8</p>
  <pre><code>import argParse
      
  #set global var 
  ARGS = None
  #a json data will be copied into CFG
  CFG=None
  # global var
  PATTERN = re.compile(r'(\d{6})')
  
  def parseCmdLineArgs():
        global ARGS
        ARGS = parser.parse_args(ARGV)
        #ARGS.arg1_value is a string
        #ARGS.arg2_val_is_jsonfile 
        CFG = json.loads(ARGS.arg2_val_is_jsonfile) #CFG[&quot;maxLen&quot;] =100 is set
  
  def some_func():
      msg=scan(PATTERN,CFG[&quot;maxLen&quot;], ARGS.arg1_value)
  </code></pre>
  <p>pytest test_app.py:</p>
  <pre><code>import app
  from app import some_func
  def test_some_func():
      some_func() 
    
  </code></pre>
  <p>Question: above test_some_func() fails.
  How to set the global variable's (CFG, PATTERN )value from here ?</p>