title: Pytest: Update a global variable in test
body: <p>I am new to Python and am using pytest for testing</p>
  
  <p>I am executing the pytest from within the python script. I have a global variable in the script which I modify based on the result in the test. The updated global variable is again used after the tests are executed.</p>
  
  <pre><code>import pytest
  global test_suite_passed
  test_suite_passed = True
  
  def test_toggle():
     global test_suite_passed
     a = True
     b = True
     c = True if a == b else False
     test_suite_passed = c
     assert c
  
  def test_switch():
     global test_suite_passed
     one = True
     two = False
     three = True if one == two else False
     if test_suite_passed:
        test_suite_passed = three
     assert three
  
  
  if __name__ == '__main__':
     pytest.main()
     if not test_suite_passed:
        raise Exception("Test suite failed")
     print "Test suite passed"
  </code></pre>
  
  <p>I have two questions:</p>
  
  <p>1) The above code snippet prints "Test suite passed", whereas I am expecting an Exception to be raised as the second test case has failed.</p>
  
  <p>2) Basically, I want a handle to the result of the pytest, through which I can get to know the number of test cases passed and failed. This shows up in the test summary. But I am looking for a object which I can use further in the script after the tests are executed </p>