title: TransactionManagementError:This is forbidden when an 'atomic' block is active while running unit test cases
body: <p>I am getting this error while I am trying to run unit test case using pytest.
  It works fine in my project but raises an error while running test case.</p>
  
  <p>My code is as following:</p>
  
  <pre><code>def saveEvents(request, request_data):
      transaction.set_autocommit(autocommit=False)
      try:
          # here is my code
      except Exception as inst:
          transaction.rollback()
          # code
      transaction.commit()
      return something
  </code></pre>
  
  <p>I read all the solutions of this type of questions, but I am puzzled why its not working with pytest. Please help.</p>