Created
January 10, 2019 10:49
-
-
Save gabriel-tincu/d8a018df040113feaf5ff59b4854b317 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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