diff options
author | Sylvain <syt@logilab.fr> | 2007-11-26 16:55:41 +0100 |
---|---|---|
committer | Sylvain <syt@logilab.fr> | 2007-11-26 16:55:41 +0100 |
commit | bb675d28e04a76ccc8c2e0cd49047074f2d807ab (patch) | |
tree | 9c0da2a1581f586f23a64ec4b10c991f81a4e0ad /pytest.py | |
parent | 7f10bb99c2c7d0cf4fd93bc03a2b9de7486722ee (diff) | |
download | logilab-common-bb675d28e04a76ccc8c2e0cd49047074f2d807ab.tar.gz |
profile option for pytest
Diffstat (limited to 'pytest.py')
-rw-r--r-- | pytest.py | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -468,6 +468,8 @@ def parseargs(): "to skip several patterns, use commas") parser.add_option('-q', '--quiet', callback=rebuild_cmdline, action="callback", help="Minimal output") + parser.add_option('-P', '--profile', default=None, dest='profile', + help="Profile execution and store data in the given file") try: from logilab.devtools.lib.coverage import Coverage @@ -523,14 +525,22 @@ def run(): tester = DjangoTester(cvg) else: tester = PyTester(cvg) + if explicitfile: + cmd, args = tester.testfile, (explicitfile,) + elif options.testdir: + cmd, args = tester.testonedir, (options.testdir, options.exitfirst) + else: + cmd, args = tester.testall, (options.exitfirst,) try: try: - if explicitfile: - tester.testfile(explicitfile) - elif options.testdir: - tester.testonedir(options.testdir, options.exitfirst) + if options.profile: + import hotshot + prof = hotshot.Profile(options.profile) + prof.runcall(cmd, *args) + prof.close() + print 'profile data saved in', options.profile else: - tester.testall(options.exitfirst) + cmd(*args) except SystemExit: raise except: |