Commit 436831db authored by Senthil Kumaran's avatar Senthil Kumaran

Issue22642 - Convert trace module's option handling mechanism from getopt to argparse.

Patch contributed by SilentGhost.
parent 121edbf7
import os import os
import sys import sys
from test.support import TESTFN, rmtree, unlink, captured_stdout from test.support import TESTFN, rmtree, unlink, captured_stdout
from test.support.script_helper import assert_python_ok, assert_python_failure
import unittest import unittest
import trace import trace
...@@ -364,6 +365,27 @@ class Test_Ignore(unittest.TestCase): ...@@ -364,6 +365,27 @@ class Test_Ignore(unittest.TestCase):
# Matched before. # Matched before.
self.assertTrue(ignore.names(jn('bar', 'baz.py'), 'baz')) self.assertTrue(ignore.names(jn('bar', 'baz.py'), 'baz'))
class TestCommandLine(unittest.TestCase):
def test_failures(self):
_errors = (
(b'filename is missing: required with the main options', '-l', '-T'),
(b'cannot specify both --listfuncs and (--trace or --count)', '-lc'),
(b'argument -R/--no-report: not allowed with argument -r/--report', '-rR'),
(b'must specify one of --trace, --count, --report, --listfuncs, or --trackcalls', '-g'),
(b'-r/--report requires -f/--file', '-r'),
(b'--summary can only be used with --count or --report', '-sT'),
(b'unrecognized arguments: -y', '-y'))
for message, *args in _errors:
*_, stderr = assert_python_failure('-m', 'trace', *args)
self.assertIn(message, stderr)
def test_listfuncs_flag_success(self):
with open(TESTFN, 'w') as fd:
self.addCleanup(unlink, TESTFN)
fd.write("a = 1\n")
status, stdout, stderr = assert_python_ok('-m', 'trace', '-l', TESTFN)
self.assertIn(b'functions called:', stdout)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment