Skip to content

Instantly share code, notes, and snippets.

@davidallsopp
Created June 25, 2015 22:03
Show Gist options
  • Save davidallsopp/e45bd14fb82ea353515b to your computer and use it in GitHub Desktop.
Save davidallsopp/e45bd14fb82ea353515b to your computer and use it in GitHub Desktop.
Ultra-simple test harness for Python. Locates all functions in the current module that start with "test", and runs them.
def test_example():
assert False, "A failing test"
if __name__ == "__main__":
tests = [(k, v) for k, v in locals().items() if k.startswith("test")]
print("%s TESTS FOUND" % len(tests))
for k, v in tests:
print(k)
v()
print("TESTS COMPLETE")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment