Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
436831db
Commit
436831db
authored
Jan 13, 2016
by
Senthil Kumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue22642 - Convert trace module's option handling mechanism from getopt to argparse.
Patch contributed by SilentGhost.
parent
121edbf7
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
156 additions
and
205 deletions
+156
-205
Lib/test/test_trace.py
Lib/test/test_trace.py
+22
-0
Lib/trace.py
Lib/trace.py
+134
-205
No files found.
Lib/test/test_trace.py
View file @
436831db
import
os
import
sys
from
test.support
import
TESTFN
,
rmtree
,
unlink
,
captured_stdout
from
test.support.script_helper
import
assert_python_ok
,
assert_python_failure
import
unittest
import
trace
...
...
@@ -364,6 +365,27 @@ class Test_Ignore(unittest.TestCase):
# Matched before.
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__'
:
unittest
.
main
()
Lib/trace.py
View file @
436831db
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment