summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_cprofile.py
diff options
context:
space:
mode:
authorStéphane Wirtel <stephane@wirtel.be>2018-10-17 10:03:40 (GMT)
committerVictor Stinner <vstinner@redhat.com>2018-10-17 10:03:40 (GMT)
commitfcd5e84a515e19409840c570730f0728e9fcfc83 (patch)
tree7e21db82d894544759edc23cc13ccbe108d224d2 /Lib/test/test_cprofile.py
parent8e73ad38ab7d218b9ef8976032865928dfad00f1 (diff)
downloadcpython-fcd5e84a515e19409840c570730f0728e9fcfc83.zip
cpython-fcd5e84a515e19409840c570730f0728e9fcfc83.tar.gz
cpython-fcd5e84a515e19409840c570730f0728e9fcfc83.tar.bz2
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>
Diffstat (limited to 'Lib/test/test_cprofile.py')
-rw-r--r--Lib/test/test_cprofile.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/test/test_cprofile.py b/Lib/test/test_cprofile.py
index 2fd67ee..406d703 100644
--- a/Lib/test/test_cprofile.py
+++ b/Lib/test/test_cprofile.py
@@ -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: