mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-23420: Verify the value of '-s' when execute the CLI of cProfile (GH-9925)
Verify the value for the parameter '-s' of the cProfile CLI. Patch by Robert Kuska. Co-authored-by: Robert Kuska <rkuska@gmail.com>
This commit is contained in:
parent
8e73ad38ab
commit
fcd5e84a51
3 changed files with 12 additions and 2 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
import sys
|
||||
from test.support import run_unittest, TESTFN, unlink
|
||||
import unittest
|
||||
|
||||
# rip off all interesting stuff from test_profile
|
||||
import cProfile
|
||||
|
@ -76,9 +77,14 @@ class CProfileTest(ProfileTest):
|
|||
# profile shouldn't be set once we leave the with-block.
|
||||
self.assertIs(sys.getprofile(), None)
|
||||
|
||||
class TestCommandLine(unittest.TestCase):
|
||||
def test_sort(self):
|
||||
rc, out, err = assert_python_failure('-m', 'cProfile', '-s', 'demo')
|
||||
self.assertGreater(rc, 0)
|
||||
self.assertIn(b"option -s: invalid choice: 'demo'", err)
|
||||
|
||||
def test_main():
|
||||
run_unittest(CProfileTest)
|
||||
run_unittest(CProfileTest, TestCommandLine)
|
||||
|
||||
def main():
|
||||
if '-r' not in sys.argv:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue