mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-69990: Make Profile.print_stats support sorting by multiple values (GH-104590)
Co-authored-by: Chiu-Hsiang Hsu
This commit is contained in:
parent
351c103134
commit
2a7a0020c9
5 changed files with 20 additions and 4 deletions
|
@ -7,7 +7,7 @@ import os
|
|||
from difflib import unified_diff
|
||||
from io import StringIO
|
||||
from test.support.os_helper import TESTFN, unlink, temp_dir, change_cwd
|
||||
from contextlib import contextmanager
|
||||
from contextlib import contextmanager, redirect_stdout
|
||||
|
||||
import profile
|
||||
from test.profilee import testfunc, timer
|
||||
|
@ -92,6 +92,11 @@ class ProfileTest(unittest.TestCase):
|
|||
self.profilermodule.run("int('1')", filename=TESTFN)
|
||||
self.assertTrue(os.path.exists(TESTFN))
|
||||
|
||||
def test_run_with_sort_by_values(self):
|
||||
with redirect_stdout(StringIO()) as f:
|
||||
self.profilermodule.run("int('1')", sort=('tottime', 'stdname'))
|
||||
self.assertIn("Ordered by: internal time, standard name", f.getvalue())
|
||||
|
||||
def test_runctx(self):
|
||||
with silent():
|
||||
self.profilermodule.runctx("testfunc()", globals(), locals())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue