title: How can I check if a warning was raised but still not to turn it into an exception
body: <p>I have a method <code>get_font</code> that can raise a <code>DefaultFontWarning</code>. I want to check if that warning was raised and to run a piece of code if it's the case.</p>
  
  <p>My current solution is</p>
  
  <pre><code>def set_font(self):
      with warnings.catch_warnings():
          warnings.filterwarnings("error")
          try:
              self.font = get_font(self.path, self.size)
          except DefaultFontWarning:
              self.is_default = True
  </code></pre>
  
  <p>This attaches <code>is_default</code> to <code>self</code>, but it also silences the warning so that user cannot see it.</p>
  
  <p>How can I check if a warning was raised but still not to turn it into an exception and output it?</p>