Skip to content

Instantly share code, notes, and snippets.

@PatrickKennedy
Created August 2, 2009 22:42
Show Gist options
  • Select an option

  • Save PatrickKennedy/160235 to your computer and use it in GitHub Desktop.

Select an option

Save PatrickKennedy/160235 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
#
def check(*tests):
print combine_results([report_result(test) for test in tests])
def report_result(test, globals={}, locals={}):
result = eval(test, globals, locals)
print "%s ... %s" % ("pass" if result else "FAIL", test)
return result
def combine_results(results):
if [x for x in results if x]:
return True
if __name__ == "__main__":
check(
'1 + 2 == 3',
'1 + 2 + 3 == 6',
'-1 + -3 == -4',
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment