Last active
March 9, 2021 15:41
-
-
Save BlairCurrey/27acfb6005a2bc57eb811cdc3be2363f to your computer and use it in GitHub Desktop.
Python Assertion Fail Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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