##// END OF EJS Templates
Fix %timeit for slow functions, by Prabhu Ramachandran....
Fix %timeit for slow functions, by Prabhu Ramachandran. From his submission on the list: Lets say you have a function that takes 2 seconds to evaluate. With the original code you are going to run that function 10 times regardless of the fact that it already takes 2 seconds and with the original code, timing this will take at least 60 seconds (with repeat=3) which is way too much.

File last commit:

r964:0a2f2117
r1920:1a1bcdc2
Show More
runtests.py
31 lines | 713 B | text/x-python | PythonLexer
""" Run ipython unit tests
This should be launched from inside ipython by "%run runtests.py"
or through ipython command line "ipython runtests.py".
"""
from IPython.external.path import path
import pprint,os
import IPython.ipapi
ip = IPython.ipapi.get()
def main():
all = path('.').files('test_*py')
results = {}
res_exc = [None]
def exchook(self,*e):
res_exc[0] = [e]
ip.IP.set_custom_exc((Exception,), exchook)
startdir = os.getcwd()
for test in all:
print test
res_exc[0] = 'ok'
os.chdir(startdir)
ip.runlines(test.text())
results[str(test)] = res_exc[0]
os.chdir(startdir)
pprint.pprint(results)
main()