title: Python unittest: Retry on failure with Nose?
body: <p>I have a test which randomly fails and I want to let it retry a number of times before sending an error message.</p>
  
  <p>I'm using python with Nose.</p>
  
  <p>I wrote the following, but unfortunately, even with the try/except handling, Nose returns an error when the test fails on the first try.</p>
  
  <pre><code>def test_something(self):
      maxAttempts = 3
      func = self.run_something
  
      attempt = 1
      while True:
          if attempt == maxAttempts:
              yield func
              break
  
          else:
              try:
                  yield func
                  break
              except:
                  attempt += 1
  
  def run_something(self):
      #Do stuff
  </code></pre>
  
  <p>Thanks</p>