Skip to content

Instantly share code, notes, and snippets.

@LiamJolly
Last active April 2, 2017 08:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LiamJolly/7c91d79b8ede2b049eecf4a4d70b9217 to your computer and use it in GitHub Desktop.
Save LiamJolly/7c91d79b8ede2b049eecf4a4d70b9217 to your computer and use it in GitHub Desktop.
A really simple example to help demonstrate mocks that throw exceptions.
def find_user(username):
if username == "user1":
return dict(name="user1", id_no="12345")
else:
raise Exception
def does_user_exist(username):
try:
find_user(username)
return True
except Exception:
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment