summaryrefslogtreecommitdiff
path: root/Lib/test
diff options
context:
space:
mode:
authorMario Corchero <mariocj89@gmail.com>2019-06-01 05:49:10 +0100
committerNick Coghlan <ncoghlan@gmail.com>2019-06-01 14:49:09 +1000
commit354227a1e90036d8c1481a211746de912c6c7c33 (patch)
treed6f17c6225b1dc76f7bae5b8399df63f3f289358 /Lib/test
parent664fe3996f7e05ae351526f02b21504bb065bcf8 (diff)
downloadcpython-git-354227a1e90036d8c1481a211746de912c6c7c33.tar.gz
Add option to trace to run modules (GH-5134)
Adds a new option in trace that allows tracing runnable modules. It is exposed as `--module module_name` as `-m` is already in use for another argument.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_trace.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/test/test_trace.py b/Lib/test/test_trace.py
index afe7902676..4bc21eae02 100644
--- a/Lib/test/test_trace.py
+++ b/Lib/test/test_trace.py
@@ -474,7 +474,7 @@ class TestCommandLine(unittest.TestCase):
def test_failures(self):
_errors = (
- (b'filename is missing: required with the main options', '-l', '-T'),
+ (b'progname 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'),
@@ -524,5 +524,10 @@ class TestCommandLine(unittest.TestCase):
self.assertIn('lines cov% module (path)', stdout)
self.assertIn(f'6 100% {TESTFN} ({filename})', stdout)
+ def test_run_as_module(self):
+ assert_python_ok('-m', 'trace', '-l', '--module', 'timeit', '-n', '1')
+ assert_python_failure('-m', 'trace', '-l', '--module', 'not_a_module_zzz')
+
+
if __name__ == '__main__':
unittest.main()