Skip to content

Instantly share code, notes, and snippets.

@gabriel-tincu
Created January 10, 2019 10:49
Show Gist options
  • Save gabriel-tincu/d8a018df040113feaf5ff59b4854b317 to your computer and use it in GitHub Desktop.
Save gabriel-tincu/d8a018df040113feaf5ff59b4854b317 to your computer and use it in GitHub Desktop.
import unittest, time
class MyResult(unittest.TestResult):
def __init__(self, stream=None, descriptions=None, verbosity=None):
super(MyResult, self).__init__(stream=None, descriptions=None, verbosity=None)
self.data = {}
def startTest(self, test):
print(test, type(test))
super(MyResult, self).startTest(test)
self.data[test] = time.time()
def stopTest(self, test):
super(MyResult, self).stopTest(test)
print("Ending test {}".format(test))
self.data[test] = time.time() - self.data[test]
def stopTestRun(self):
print(self.data)
super(MyResult, self).stopTestRun()
if __name__ == '__main__':
runner = unittest.TextTestRunner(resultclass=MyResult)
unittest.main(module=None, testRunner=runner)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment