Skip to content

Instantly share code, notes, and snippets.

@themichaelyang
Last active November 9, 2018 21:41
Show Gist options
  • Save themichaelyang/072082faa6f3f456c64d1b2b4685dfb9 to your computer and use it in GitHub Desktop.
Save themichaelyang/072082faa6f3f456c64d1b2b4685dfb9 to your computer and use it in GitHub Desktop.
check( <fn_to_test> )( <fn_args> )( <expected_return> )
def check(fn):
def run_check(expected, *args):
result = fn(*args)
if result == expected:
print("Test passed: " + fn.__name__ + str(args) + ' == ' + str(expected))
else:
print("Test failed: " + fn.__name__ + str(args))
print(" - Expected: " + str(expected))
print(" - Received: " + str(result))
return lambda *args: lambda expected: run_check(expected, *args)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment