title: Simulate clearing cookies after each request in a Python unittest
body: <p>I need to write a unit test to determine if a rate limiting method works even if the user clears cookies after each request.  The existing rate limiting method uses the session to count requests.  Our security guru says this is easily bypassed by clearing cookies after each request. I don't know how to simulate a new session or clearing cookies in the unit test.  Server is Python2.7 using Flask.  Existing code:</p>
  
  <pre><code>def test_retry_protection(self):
      #
      prev1 = app.config['RETRY_PROTECTION_COUNT']
      app.config['RETRY_PROTECTION_COUNT'] = 3
      prev2 = app.config['RETRY_PROTECTION_SECONDS']
      app.config['RETRY_PROTECTION_SECONDS'] = 5
      username = 'retry.me'
      password = 'ke52u&amp;%y!jfueQ'
      result = self.app.post('/add_password',
                             data=dict(username=username, password1=password,
                                       password2=password))
      assert '": "ok"' in result.data, result.data
  
      for x in range(app.config['RETRY_PROTECTION_COUNT'] - 1):
          result = self.app.post('/update_password',
                                 data=dict(username=username, password1=password,
                                           password2=password, password_old=password + 'wrong'))
          assert 'User and password not correct' in result.data, result.data
  
      result = self.app.post('/update_password',
                             data=dict(username=username, password1=password + 'change',
                                       password2=password + 'change', password_old=password))
      assert 'Excessive usage - wait 10 minutes to try again' in result.data, result.data
      time.sleep(app.config['RETRY_PROTECTION_SECONDS'] + 1)
      result = self.app.post('/update_password',
                             data=dict(username=username, password1=password + 'change',
                                       password2=password + 'change', password_old=password))
      assert '": "ok"' in result.data, result.data
      app.config['RETRY_PROTECTION_COUNT'] = prev1
      app.config['RETRY_PROTECTION_SECONDS'] = prev2
  </code></pre>