Skip to content

Instantly share code, notes, and snippets.

@BlairCurrey
Last active March 9, 2021 15:41
Show Gist options
  • Save BlairCurrey/27acfb6005a2bc57eb811cdc3be2363f to your computer and use it in GitHub Desktop.
Save BlairCurrey/27acfb6005a2bc57eb811cdc3be2363f to your computer and use it in GitHub Desktop.
Python Assertion Fail Test
# In this python command-line assertion test, ENTER
# results in an assertion failure which stops the program.
# Anything else will continue, which results in being asked for
# input again and again.
while True:
# Get command-line input
val = input("Press enter to test assertion failure: ")
# Enter for assertion failure
if val == "":
assert val == 1, "assertion failed"
# Anything else is an assertion pass which interrupts program
else:
assert val == val, "assertion passed"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment