Last active
November 12, 2017 09:17
-
-
Save jaycody/1d3a50e7336519e439083e26964cad6a to your computer and use it in GitHub Desktop.
Function validator function compares got against expected and reports results.
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
#! /usr/bin/python -tt | |
"""simple function tester""" | |
def do(x): | |
return x | |
def test(got, expected): | |
"""Compare what you got with what you expected. | |
Report back please | |
""" | |
if got == expected: | |
results = ' OK' | |
else: | |
results = ' X' | |
print '{:5s} got: {:10s} expected: {}'.format(results, repr(got), repr(expected)) | |
if __name__ == '__main__': | |
test(do(10), 10) | |
test(do(10), 9990) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment