Skip to content

Instantly share code, notes, and snippets.

@jaycody
Last active November 12, 2017 09:17
Show Gist options
  • Save jaycody/1d3a50e7336519e439083e26964cad6a to your computer and use it in GitHub Desktop.
Save jaycody/1d3a50e7336519e439083e26964cad6a to your computer and use it in GitHub Desktop.
Function validator function compares got against expected and reports results.
#! /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