Skip to content

Instantly share code, notes, and snippets.

@seanjensengrey
Created May 4, 2014 16:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seanjensengrey/d6303c412ed0725d4398 to your computer and use it in GitHub Desktop.
Save seanjensengrey/d6303c412ed0725d4398 to your computer and use it in GitHub Desktop.
minimal test harness for python (nose like)
import types
def test_foo():
assert 1 == 2, '1 must equal 2'
def test_bar():
pass
if __name__ == "__main__":
test_funcs = []
for o in globals().keys():
if o.startswith('test_'):
if type(globals()[o]) == types.FunctionType:
test_funcs.append(globals()[o])
success = []
failure = []
for tf in test_funcs:
try:
tf()
success.append(tf)
except Exception, e:
failure.append((tf,e))
print success
print failure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment