Created
July 10, 2019 21:06
-
-
Save ostrokach/fc5bae0893f29be0c669ccb2b06c8ec8 to your computer and use it in GitHub Desktop.
Print run-time statistics for every test
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 | |
from cProfile import Profile | |
from pstats import Stats | |
def MyTest(unittest.TestCase): | |
def setUp(self): | |
"""init each test""" | |
self.pr = Profile() | |
self.pr.enable() | |
def tearDown(self): | |
"""finish any test""" | |
p = Stats(self.pr) | |
p.strip_dirs() | |
p.sort_stats('cumtime') | |
p.print_stats() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment