title: Catch response code with Python 2.6 unittest
body: <p>Using unittest to test some edge cases with an API. All of these cases return 400-series response codes using custom exception classes. Unfortunately, I can't seem to find a way to catch these custom exceptions or to read the response codes in the unittest check itself.</p>
  
  <p>What I have been receiving is an 'AppError' exception with a message mentioning it is a 400 response rather than a 200 or 300. I want to avoid parsing the exception message if I can. This also needs to work on Python 2.6+. How can I either catch the custom exceptions in my unittest check, or determine the response code causing the error without parsing the exception message?</p>